两个变量+一个图
The attached CSV file contains 1) net electricity production from natural gas across US states (in Megawatt hours abbreviated as Mwh) and 2) the percent of total US electricity production from natural gas produced by each state for the years 2009 and 2018. Data are from the U.S. Energy Information Administration (https://www.eia.gov/electricity/data/state). Follow the instructions and answer ALL of the questions below:
• Read the dataset into RStudio using the read.csv() function.
• In R, create two new variables:
• Percent change in net electricity production from natural gas for each state from 2009 to 2018.
• Change in percent of total US electricity production from natural gas produced by each state from 2009 to 2018.
• Using the micromapST() function, create a linked micromap that contains the following features and formatting exactly as follows:
• The first column should display the maps where states above the median are highlighted in all maps above the median row and states below the median are highlighted in all maps below the median row.
• The second column should display the names of the states and their corresponding colors (full names or abbreviations are acceptable).
• The third column should display the net electricity production from natural gas in 2018 as a bar with a reference line for the average US net electricity production from natural gas, which is 29978213 Mwh.
• The fourth column should display the percent change in net electricity production from natural gas from 2009 to 2018 as an arrow (starting at 0 and pointing to the percent change) with a reference line at 0.
• The fifth column should display the change in percent of total US electricity production from natural gas produced by each state from 2009 to 2018 as an arrow (starting at 0 and pointing to the change) with a reference line at 0.
• The rows should be sorted according to the change in percent of total US electricity production from natural gas produced by each state from 2009 to 2018 in decreasing order from top to bottom.
• Appropriate titles and labeling should be included to completely and accurately describe the information in the micromap and in each column (including the source of the information).