INTRODUCTION
Dataset: EIA Energy Information on Renewable Energy Consumption by Source, January 2013 to August 2017.
Units of raw data are quadrillion BTU.
SET-UP
Load required libraries.
library(knitr)
library(tibble)
library(ggplot2)
library(DT)
RAW DATA
Load raw data file into R Studio, scanning the first two rows to combine the two row header into one column name.
renewable_raw <- read.csv("~/Desktop/renewableraw.csv", skip = 2, header = FALSE)
header_rows <- read.csv("~/Desktop/renewableraw.csv", nrows=2, header=FALSE)
new_header <- sapply(header_rows, paste, collapse="_")
names(renewable_raw) <- new_header
renewable_raw[1:10,1:3]
## Type_ 2013_January 2013_February
## 1 Electric Power Sector NA NA
## 2 Geothermal . 0.013 0.012
## 3 Hydroelectric Power (a) . 0.234 0.191
## 4 Solar (b) . 0.003 0.004
## 5 Waste Biomass (c) . 0.022 0.019
## 6 Wood Biomass . 0.017 0.015
## 7 Wind . 0.141 0.134
## 8 Subtotal . 0.429 0.376
## 9 Industrial Sector NA NA
## 10 Biofuel Losses and Co-products (d) . 0.055 0.050
SUBSET DATA
Create a datasubset with only the Residential Consumption of Renewable Energy rows 24 through 27, all months and years.
Replace the first row of the new table with the first row of the raw table to retain the months designation.
renewable_raw[,1]
## [1] Electric Power Sector
## [2] Geothermal .
## [3] Hydroelectric Power (a) .
## [4] Solar (b) .
## [5] Waste Biomass (c) .
## [6] Wood Biomass .
## [7] Wind .
## [8] Subtotal .
## [9] Industrial Sector
## [10] Biofuel Losses and Co-products (d) .
## [11] Geothermal .
## [12] Hydroelectric Power (a) .
## [13] Solar (b) .
## [14] Waste Biomass (c) .
## [15] Wood Biomass .
## [16] Subtotal .
## [17] Commercial Sector
## [18] Geothermal .
## [19] Solar (b) .
## [20] Waste Biomass (c) .
## [21] Wood Biomass .
## [22] Subtotal .
## [23] Residential Sector
## [24] Geothermal .
## [25] Solar (e) .
## [26] Wood Biomass .
## [27] Subtotal .
## [28] Transportation Sector
## [29] Biomass-based Diesel (f) .
## [30] Ethanol (f) .
## [31] Subtotal .
## [32] All Sectors Total
## [33] Biomass-based Diesel (f) .
## [34] Biofuel Losses and Co-products (d) .
## [35] Ethanol (f) .
## [36] Geothermal .
## [37] Hydroelectric Power (a) .
## [38] Solar (b)(e) .
## [39] Waste Biomass (c) .
## [40] Wood Biomass .
## [41] Wind .
## [42] Total Consumption .
## 21 Levels: Subtotal . ... Transportation Sector
renewable_res <- renewable_raw[24:27,]
datatable(renewable_res)
CREATE DATAFRAME
Build vectors from the raw data so it will be easier to manipulate
Convert the units because Quadrillion BTU (“Quads”) is not commonly used, instead use Giga-Watthours (“GWh”)
Conversion factor: 1 Quad = 293,071.07 GWh
Round the numbers for ease of viewing
Time <- c(new_header)
Geothermal_GWh <- round(mapply(`*`, as.numeric(c(renewable_res[1,])), 293071.07), digits = 1)
Solar_GWh <- round(mapply(`*`, as.numeric(c(renewable_res[2,])), 293071.07), digits = 1)
Biomass_GWh <- round(mapply(`*`, as.numeric(c(renewable_res[3,])) , 293071.07), digits = 1)
Total_GWh <- round(mapply(`*`, as.numeric(c(renewable_res[4,])), 293071.07), digits = 1)
Create a dataframe from the original data making the rows vectors
renewable_res_GWh <- data.frame(Time, Geothermal_GWh, Solar_GWh, Biomass_GWh, Total_GWh)
datatable(renewable_res_GWh)
VISUALIZE
Plot the data to visualize the change in renewable energy consumption in the residential sector and to determine if one technology is contributing more than others to thte overall trends.
Plot the total renewable energy consumed in the residential sector using blue.
ggplot(data=renewable_res_GWh, aes(x=Time, y=Total_GWh, group=1)) +
geom_line(color="#0066ff", size=1) +
geom_point(color="#0066ff", size=2) +
scale_x_discrete(breaks=c("2013","2014","2015","2016","2017")) +
ggtitle("Monthly Consumption of Total Renewable Energy in GWh for Residential Sector") +
labs(x="January 2013 through August 2017", y="Consumption in GWh") +
theme(axis.title.y = element_text(size=12, color="#666666")) +
theme(axis.text = element_text(size=12, family="Trebuchet MS")) +
theme(plot.title = element_text(size=12, family="Trebuchet MS", face="bold", hjust=0, color="#666666"))
## Warning in plyr::split_indices(scale_id, n): '.Random.seed' is not an
## integer vector but of type 'NULL', so ignored

Plot the solar component of the renewable energy consumed in the residential sector using red.
ggplot(data=renewable_res_GWh, aes(x=Time, y=Solar_GWh, group=1)) +
geom_line(color="#aa0022", size=1) +
geom_point(color="#aa0022", size=2) +
scale_x_discrete(breaks=c("2013","2014","2015","2016","2017")) +
ggtitle("Monthly Consumption of Solar Energy in GWh for Residential Sector") +
labs(x="January 2013 through August 2017", y="Consumption in GWh") +
theme(axis.title.y = element_text(size=12, color="#666666")) +
theme(axis.text = element_text(size=12, family="Trebuchet MS")) +
theme(plot.title = element_text(size=12, family="Trebuchet MS", face="bold", hjust=0, color="#666666"))

ANALYZE
These two visualizations shouw that overall the total monthly renewable energy consumed by the residential sector has been volatile from January 2013 to August 2017 and overall has not grown. However, the monthly consumption of solar has grown dramatically across the residential sector as evident in the second graph.
Also interesting in the second graph is the clear seasonality of solar, which fluctuates across the winter, spring, summer, and fall seasons.