The Growth of Renewable Energy

James
6/13/2013

How have renewables grown?

plot of chunk unnamed-chunk-2

How do we get to here?

  • First load our data and subset the renewables:
EnergyProd <- read.csv("EnergyProd.csv", 
                       header=TRUE,nrows=62)
RenewProd <- subset(EnergyProd, 
                    select=c("Year",
                             "Hydro",
                             "Geothermal",
                             "Solar",
                             "Wind",
                             "Biomass"))
  • What it looks like:
head(RenewProd)
  Year   Hydro Geothermal Solar Wind Biomass
1 1949 1424722         NA    NA   NA 1549262
2 1950 1415411         NA    NA   NA 1562307
3 1951 1423795         NA    NA   NA 1534669
4 1952 1465812         NA    NA   NA 1474369
5 1953 1412859         NA    NA   NA 1418601
6 1954 1359772         NA    NA   NA 1394327

How do we get to here?

  • Then melt our data from a 'wide' format to a 'long' format
RenewProdLong <- melt(RenewProd, 
                      id.vars="Year")
names(RenewProdLong) <- c("Year", 
                          "Source", 
                          "Power")

To better show how our data has melted

  • Before
  Year   Hydro Geothermal Solar Wind Biomass
1 1949 1424722         NA    NA   NA 1549262
2 1950 1415411         NA    NA   NA 1562307
3 1951 1423795         NA    NA   NA 1534669
4 1952 1465812         NA    NA   NA 1474369
5 1953 1412859         NA    NA   NA 1418601
6 1954 1359772         NA    NA   NA 1394327

To better show how our data has melted

  • After
head(RenewProdLong)
    Year     Source   Power
1   1949      Hydro 1424722
63  1949 Geothermal      NA
125 1949      Solar      NA
187 1949       Wind      NA
249 1949    Biomass 1549262
2   1950      Hydro 1415411

And then we plot!

require(ggplot2)
p <- ggplot(data=RenewProdLong,
            aes(x=Year,y=Power ,fill=Source))
p <- p + geom_bar(stat='identity',
                  position=position_stack(width=2.9))
p <- p + scale_fill_brewer(type='qual',
                           palette=2)
p <- p + theme(legend.text = element_text(size=40), 
          axis.text = element_text(size=50),
          axis.title.x = element_text(size=50),
          axis.title.y = element_text(size=50))

And then we plot!

p

plot of chunk unnamed-chunk-10

As an added bonus...

  • What if we're interested in renewables as a proportion of total energy production?
names(EnergyProd)
 [1] "Year"       "Coal"       "NatGas"     "CrudeOil"   "NGPL"      
 [6] "TotalFF"    "Nuclear"    "Hydro"      "Geothermal" "Solar"     
[11] "Wind"       "Biomass"    "TotalRenew" "Total"     
require(plyr)
NewProd <- join(RenewProdLong, 
                EnergyProd[, c(1,13,14)], 
                by="Year")

So now our data looks like:

head(NewProd)
  Year     Source   Power TotalRenew    Total
1 1949      Hydro 1424722    2973984 31722160
2 1949 Geothermal      NA    2973984 31722160
3 1949      Solar      NA    2973984 31722160
4 1949       Wind      NA    2973984 31722160
5 1949    Biomass 1549262    2973984 31722160
6 1950      Hydro 1415411    2977718 35540384

Total renewable energy produced as a percent of total energy produced

q <- ggplot(data=NewProd, 
            aes(x=Year,y=Power/Total, 
                fill=Source))
q <- q + geom_bar(stat='identity', 
                  position=position_stack(width=2.9))
q <- q + scale_fill_brewer(type='qual',
                           palette=2)
q <- q + theme(legend.text = element_text(size=40), 
          axis.text = element_text(size=50),
          axis.title.x = element_text(size=50),
          axis.title.y = element_text(size=50))

Renewables in terms of production:

plot of chunk unnamed-chunk-15

Renewables as a percent of total production:

plot of chunk unnamed-chunk-16