FOCUS | numeric


Power Banner

Here is a simple analysis report of the power source used in electric power plants from 2003 to 2013. The data can be found at eia.gov. R, LaTeX and Markdown were used to render the report as a PDF. The R Markdown code is pasted below. Links to each of the datasets and the Markdown file can be found at the bottom of the page. I may extend this later and do some statistical analysis - but for now the file is mostly just plots with some basic comments. You can click on here and see the output:

Rmd file rendered as PDF

Markdown is an excellent extension to R. However, there are a few things that need improvement. For instance, there is no good way center text. Also, line breaks are specified by putting two spaces after a line of R code... This is far from ideal because 'white space' is typically invisible in a text editor. I use "Notepadqq" on Linux to author most of the code I write. As flexible as "Notepadqq" is, adding some marking for empty spaces makes everything nearly unreadable. I would prefer, in all cases, to have explicit ways to add new lines, center text - or whatever else. LaTeX, on the other hand, is completely configurable. Whatever you want to do in LaTeX can be done!

To run the Markdown file you will need all of the datasets. They are just little *.csv files that format the data from eia.gov in a way that makes it easy to pull them into R. The R language can read *.xlsx files but I wouldn't recommend it. I added comments to the *.Rmd file to make it easy to understand and edit. If you want to run the *.Rmd file, I would suggest downloading the file rather than trying to run a copy of the code pasted into the webpage.

```{r echo=FALSE}
# Table 4.1. Count of Electric Power Industry Power Plants, by Sector, by Predominant Energy Sources within Plant, 2003 through 2013
# Markdown report written in R by Eric N Johnson, Focus | Numeric
# See http://FocusNumeric.net/ElectricPowerIndustry.html
# Usage in R GUI:  render("ElectricPowerIndustryPlants.Rmd", output_format="pdf_document",output_file=paste("Whatever", Sys.Date(), ".pdf"))
	require(rmarkdown)
	require(xtable)
	require(knitr)
	require(psych)
	require(colorRamps)
# Data found at:  http://www.eia.gov/electricity/data.cfm
# See "Generation and thermal output"
# The data was made R-ready by putting each category in a CSV file.
# R can pull data right off the web - but I'd rather work with a local copy of it.
# Define constants
firstYear <- 2003
lastYear <- 2013
colors <- green2red(7)
```
```{r echo=FALSE}
# Import each of the sets for use
AllSectors <- read.csv("AllSectors.csv", header=TRUE, stringsAsFactors=FALSE)
ElectricUtilities <- read.csv("ElectricUtilities.csv", header=TRUE, stringsAsFactors=FALSE)
CommercialSector <- read.csv("CommercialSector.csv", header=TRUE, stringsAsFactors=FALSE)
IndustrialSector <- read.csv("IndustrialSector.csv", header=TRUE, stringsAsFactors=FALSE)
Independent_Combined <- read.csv("Independent_Combined.csv", header=TRUE, stringsAsFactors=FALSE)
Independent_NonCombined <- read.csv("Independent_NonCombined.csv", header=TRUE, stringsAsFactors=FALSE)
CommercialSector <- read.csv("CommercialSector.csv", header=TRUE, stringsAsFactors=FALSE)
IndustrialSector <- read.csv("IndustrialSector.csv", header=TRUE, stringsAsFactors=FALSE)
CoalData <- read.csv("CoalData.csv", header=TRUE, stringsAsFactors=FALSE)
GreenhouseGases <- read.csv("GreenhouseGases2.csv", header=TRUE, stringsAsFactors=FALSE)
# Define vectors for plotting and analysis.  Note:  These were created by a little script I wrote. 
Years <- seq(firstYear,lastYear,1)
# All sectors
AllSect.Coal <- AllSectors$Coal[1:11]
AllSect.Petrol <- AllSectors$Petroleum[1:11]
AllSect.NGas <- AllSectors$Natural.Gas[1:11]
AllSect.OGas <- AllSectors$Other.Gases[1:11]
AllSect.Nuke <- AllSectors$Nuclear[1:11]
AllSect.Hydro <- AllSectors$Hydroelectric.Conventional[1:11]
AllSect.ORenewable <- AllSectors$Other.Renewables[1:11]
AllSect.HydroPS <- AllSectors$Hydroelectric.Pumped.Storage[1:11]
AllSect.OSources <- AllSectors$Other.Energy.Sources[1:11]
# Electric Utilities
ElecUtils.Coal <- ElectricUtilities$Coal[1:11]
ElecUtils.Petrol <- ElectricUtilities$Petroleum[1:11]
ElecUtils.NGas <- ElectricUtilities$Natural.Gas[1:11]
ElecUtils.OGas <- ElectricUtilities$Other.Gases[1:11]
ElecUtils.Nuke <- ElectricUtilities$Nuclear[1:11]
ElecUtils.Hydro <- ElectricUtilities$Hydroelectric.Conventional[1:11]
ElecUtils.ORenewable <- ElectricUtilities$Other.Renewables[1:11]
ElecUtils.HydroPS <- ElectricUtilities$Hydroelectric.Pumped.Storage[1:11]
ElecUtils.OSources <- ElectricUtilities$Other.Energy.Sources[1:11]
# Commerical Sector
ComSect.Coal <- CommercialSector$Coal[1:11]
ComSect.Petrol <- CommercialSector$Petroleum[1:11]
ComSect.NGas <- CommercialSector$Natural.Gas[1:11]
ComSect.OGas <- CommercialSector$Other.Gases[1:11]
ComSect.Nuke <- CommercialSector$Nuclear[1:11]
ComSect.Hydro <- CommercialSector$Hydroelectric.Conventional[1:11]
ComSect.ORenewable <- CommercialSector$Other.Renewables[1:11]
ComSect.HydroPS <- CommercialSector$Hydroelectric.Pumped.Storage[1:11]
ComSect.OSources <- CommercialSector$Other.Energy.Sources[1:11]
# Industrial Sector
IndustSect.Coal <- IndustrialSector$Coal[1:11]
IndustSect.Petrol <- IndustrialSector$Petroleum[1:11]
IndustSect.NGas <- IndustrialSector$Natural.Gas[1:11]
IndustSect.OGas <- IndustrialSector$Other.Gases[1:11]
IndustSect.Nuke <- IndustrialSector$Nuclear[1:11]
IndustSect.Hydro <- IndustrialSector$Hydroelectric.Conventional[1:11]
IndustSect.ORenewable <- IndustrialSector$Other.Renewables[1:11]
IndustSect.HydroPS <- IndustrialSector$Hydroelectric.Pumped.Storage[1:11]
IndustSect.OSources <- IndustrialSector$Other.Energy.Sources[1:11]
# Independent Combined
IndepComb.Coal <- Independent_Combined$Coal[1:11]
IndepComb.Petrol <- Independent_Combined$Petroleum[1:11]
IndepComb.NGas <- Independent_Combined$Natural.Gas[1:11]
IndepComb.OGas <- Independent_Combined$Other.Gases[1:11]
IndepComb.Nuke <- Independent_Combined$Nuclear[1:11]
IndepComb.Hydro <- Independent_Combined$Hydroelectric.Conventional[1:11]
IndepComb.ORenewable <- Independent_Combined$Other.Renewables[1:11]
IndepComb.HydroPS <- Independent_Combined$Hydroelectric.Pumped.Storage[1:11]
IndepComb.OSources <- Independent_Combined$Other.Energy.Sources[1:11]
# Independent Non-Combined
IndepNComb.Coal <- Independent_NonCombined$Coal[1:11]
IndepNComb.Petrol <- Independent_NonCombined$Petroleum[1:11]
IndepNComb.NGas <- Independent_NonCombined$Natural.Gas[1:11]
IndepNComb.OGas <- Independent_NonCombined$Other.Gases[1:11]
IndepNComb.Nuke <- Independent_NonCombined$Nuclear[1:11]
IndepNComb.Hydro <- Independent_NonCombined$Hydroelectric.Conventional[1:11]
IndepNComb.ORenewable <- Independent_NonCombined$Other.Renewables[1:11]
IndepNComb.HydroPS <- Independent_NonCombined$Hydroelectric.Pumped.Storage[1:11]
IndepNComb.OSources <- Independent_NonCombined$Other.Energy.Sources[1:11]
# Coal Data
Coal.Thousands.Tons <- CoalData$Receipts.Thousand.Tons[1:11]
Coal.Sulfer.Percent <- CoalData$Mean.Sulfur.Percent.By.Weight[1:11]
Coal.Mean.Dollars.MMBtu <- CoalData$Mean.Dollars.per.MMBtu[1:11]
Coal.Mean.Dollars.Ton <- CoalData$Mean.Dollars.per.Ton[1:11]
# Greenhouse Gases
# Named with R prefix to avoid conflicting with built-in R datasets
# Not used with this version
RCO2 <- as.numeric(GreenhouseGases$CO2[1:11])
RSO2 <- as.numeric(GreenhouseGases$SO2[1:11])
RNOx <- as.numeric(GreenhouseGases$NOx[1:11])
```
```{r echo=FALSE, results='asis'}
# For debugging, if necessary.
#print(AllSect.Coal)
#print(AllSect.Petrol)
#print(AllSect.NGas)
#print(AllSect.OGas)
#print(AllSect.Nuke)
#print(AllSect.Hydro)
#print(AllSect.ORenewable)
#print(AllSect.HydroPS)
#print(AllSect.OSources)
```
**Electric Power Industry Plant Analysis**   
[Data Sources available Here](http://www.eia.gov/electricity/data.cfm)  
Produced with R, Markdown, and  \LaTeX
  
*Eric Johnson : [Focus | Numeric](http://focusnumeric.net)*  
  
**Electric Power Industry Power Plants by Predominant Energy Sources within Plant**   
**2003 through 2013**  
  
***All Sources***  
  
1. Coal is still the dominant energy source for industry power plants in spite of a drop of `r abs(AllSect.Coal[11]-AllSect.Coal[1])` 
coal-powered plants between 2003 and 2013.
2. The number of both petroleum and nuclear power plants dropped.
3. The number of natural gas, other gas, conventional and pumped storage hydroelectric, other, and other renewables increased.
4. Other renewable sources had the largest increase, with  `r abs(AllSect.ORenewable[11]-AllSect.ORenewable[1])` added units, over this 
period.
  
In 2013, there were

*  `r AllSect.Coal[11]` coal plants,
*  `r AllSect.Petrol[11]` petroleum plants,
*  `r AllSect.NGas[11]` natural gas plants,
*  `r AllSect.Nuke[11]` nuclear power plants,
*  `r AllSect.Hydro[11]` conventional hydroelectric plants,
*  `r AllSect.ORenewable[11]` other renewable plants,
*  `r AllSect.HydroPS[11]` pumped storage hydroelectric plants, and
*  `r AllSect.OSources[11]` other plants  

in operation.  
```{r fig.width=8, fig.height=5.25, echo=FALSE, results='asis'}
# All sectors	
    plot(Years, AllSect.Coal, main="All Sectors", xlab = "Year", ylab = "Count of Electric Power Industry Power Plants", type="l", 
    col="black", axes=TRUE, lwd = 3, bty='L',ylim=c(0,650))
	lines(Years, AllSect.Coal, lty=3)
	points(Years, AllSect.Coal, pch=0, bg="black")
	lines(Years, AllSect.Petrol, col=colors[1], lwd=3)
	lines(Years, AllSect.Petrol, lty=3)
	points(Years, AllSect.Petrol, pch=1, bg=colors[1])
	lines(Years, AllSect.NGas, col=colors[2], lwd=3)
	lines(Years, AllSect.NGas, lty=3)
	points(Years, AllSect.NGas, pch=2, bg=colors[2])
	lines(Years, AllSect.OGas, col=colors[3], lwd=3)
	lines(Years, AllSect.OGas, lty=3)
	points(Years, AllSect.OGas, pch=5, bg=colors[3])
	lines(Years, AllSect.Nuke, col=colors[4], lwd=3)
	lines(Years, AllSect.Nuke, lty=3)
	points(Years, AllSect.Nuke, pch=6, bg=colors[4])
	lines(Years, AllSect.Hydro, col=colors[5], lwd=3)
	lines(Years, AllSect.Hydro, lty=3)
	points(Years, AllSect.Hydro, pch=21, bg=colors[5])
	lines(Years, AllSect.ORenewable, col=colors[6], lwd=3)
	lines(Years, AllSect.ORenewable, lty=3)
	points(Years, AllSect.ORenewable, pch=22, bg=colors[6])
	lines(Years, AllSect.HydroPS, col=colors[7], lwd=3)
	lines(Years, AllSect.HydroPS, lty=3)
	points(Years, AllSect.HydroPS, pch=23, bg=colors[7])
	lines(Years, AllSect.OSources, col="blue", lwd=3)
	lines(Years, AllSect.OSources, lty=3)
	points(Years, AllSect.OSources, pch=24, bg="blue")
	legend("left", inset=.05, title="Source",
   c("Coal","Petroleum","Natural Gas","Other Gas","Nuclear","Hydroelectric","Other Renewable","Hydroelectric Pumped Storage",
   "Other Sources"), fill=c("black",colors,"blue"), horiz=FALSE)
    box()
```
The average rate of change for each type of plant per year were as follows:

*  `r (AllSect.Coal[11]-AllSect.Coal[1])/(Years[11]-Years[1])` coal plants / year,
*  `r (AllSect.Petrol[11]-AllSect.Petrol[1])/(Years[11]-Years[1])` petroleum plants / year,
*  `r (AllSect.NGas[11]-AllSect.NGas[1])/(Years[11]-Years[1])` natural gas plants / year,
*  `r (AllSect.Nuke[11]-AllSect.Nuke[1])/(Years[11]-Years[1])` nuclear power plants / year,
*  `r (AllSect.Hydro[11]-AllSect.Hydro[1])/(Years[11]-Years[1])` conventional hydroelectric plants / year,
*  `r (AllSect.ORenewable[11]-AllSect.ORenewable[1])/(Years[11]-Years[1])` other renewable plants / year,
*  `r (AllSect.HydroPS[11]-AllSect.HydroPS[1])/(Years[11]-Years[1])` pumped storage hydroelectric plants / year, and
*  `r (AllSect.OSources[11]-AllSect.OSources[1])/(Years[11]-Years[1])` other plants / year.    
  
Changes in the number of plants can be more easily seen when coal is removed.  
  

```{r fig.width=8, fig.height=5.25, echo=FALSE, results='asis'}
# All sectors, coal excluded  
    plot(Years, AllSect.Petrol, main="All Sectors, Coal Excluded", xlab = "Year", ylab = "Count of Electric Power Industry Power Plants", type="l", col=colors[1], axes=TRUE, lwd = 3, bty='L',ylim=c(20,80))
	lines(Years, AllSect.Petrol, lty=3)
	points(Years, AllSect.Petrol, pch=0, bg=colors[1])
	lines(Years, AllSect.NGas, col=colors[2], lwd=3)
	lines(Years, AllSect.NGas, lty=3)
	points(Years, AllSect.NGas, pch=2, bg=colors[2])
	lines(Years, AllSect.OGas, col=colors[3], lwd=3)
	lines(Years, AllSect.OGas, lty=3)
	points(Years, AllSect.OGas, pch=5, bg=colors[3])
	lines(Years, AllSect.Nuke, col=colors[4], lwd=3)
	lines(Years, AllSect.Nuke, lty=3)
	points(Years, AllSect.Nuke, pch=6, bg=colors[4])
	lines(Years, AllSect.Hydro, col=colors[5], lwd=3)
	lines(Years, AllSect.Hydro, lty=3)
	points(Years, AllSect.Hydro, pch=21, bg=colors[5])
	lines(Years, AllSect.ORenewable, col=colors[6], lwd=3)
	lines(Years, AllSect.ORenewable, lty=3)
	points(Years, AllSect.ORenewable, pch=22, bg=colors[6])
	lines(Years, AllSect.HydroPS, col=colors[7], lwd=3)
	lines(Years, AllSect.HydroPS, lty=3)
	points(Years, AllSect.HydroPS, pch=23, bg=colors[7])
	lines(Years, AllSect.OSources, col="blue", lwd=3)
	lines(Years, AllSect.OSources, lty=3)
	points(Years, AllSect.OSources, pch=24, bg="blue")
    box()
```
```{r fig.width=8, fig.height=4.25, echo=FALSE, results='asis'}
	plot(8, 8, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 100), ylim = c(0,100))
	legend("center", inset=.05, title="Legend", c("Petroleum","Natural Gas","Other Gas","Nuclear","Hydroelectric","Other Renewable",
  "Hydroelectric Pumped Storage","Other Sources"), fill=c(colors,"blue"), horiz=FALSE)
```
\pagebreak

***Electric Utilities***

---------

1. Hydroelectric, petroleum, and natural gas plants dominate electric utilities.
2. The number of coal plants has dropped somewhat over the period from 2003 to 2013, from `r ElecUtils.Coal[1]` to `r ElecUtils.Coal[11]` plants.
3. Other renewable sources had the largest increase in plants with an increase of `r ElecUtils.OSources[11]-ElecUtils.OSources[1]` 
plants.
  
In 2013, there are `r ElecUtils.Coal[11]` coal plants, `r ElecUtils.Petrol[11]` petroleum plants, `r ElecUtils.NGas[11]` natural gas 
plants, `r ElecUtils.Nuke[11]` nuclear power plants, `r ElecUtils.Hydro[11]` conventional hydroelectric plants, `r ElecUtils.ORenewable[11]` other renewable plants, `r ElecUtils.HydroPS[11]` pumped storage hydroelectric plants, and `r ElecUtils.OSources[11]` other plants  
in operation at electric utilities.  

```{r fig.width=8, fig.height=5.25, echo=FALSE, results='asis'}
# Electric Utilities	
# color pattern is "matlab.like" from colorRamps package
colorsEU <- matlab.like(9)
allUtils <- c(ElecUtils.Coal, ElecUtils.Petrol, ElecUtils.NGas, ElecUtils.OGas, ElecUtils.Nuke, ElecUtils.Hydro, ElecUtils.HydroPS, ElecUtils.ORenewable, ElecUtils.OSources)
maxValue <- max(allUtils)
minValue <- min(allUtils)
    plot(Years, ElecUtils.Coal, main="Electric Utilities", xlab = "Year", ylab = "Count of Electric Power Industry Power Plants", type="l", col=colorsEU[1], axes=TRUE, lwd = 3, bty='L',ylim=c(minValue,maxValue))
	lines(Years, ElecUtils.Coal, lty=3)
	points(Years, ElecUtils.Coal, pch=0, bg=colorsEU[1])
	lines(Years, ElecUtils.Petrol, col=colorsEU[2], lwd=3)
	lines(Years, ElecUtils.Petrol, lty=3)
	points(Years, ElecUtils.Petrol, pch=1, bg=colorsEU[2])
	lines(Years, ElecUtils.NGas, col=colorsEU[3], lwd=3)
	lines(Years, ElecUtils.NGas, lty=3)
	points(Years, ElecUtils.NGas, pch=2, bg=colorsEU[3])
	lines(Years, ElecUtils.OGas, col=colorsEU[4], lwd=3)
	lines(Years, ElecUtils.OGas, lty=3)
	points(Years, ElecUtils.OGas, pch=5, bg=colorsEU[4])
	lines(Years, ElecUtils.Nuke, col=colorsEU[5], lwd=3)
	lines(Years, ElecUtils.Nuke, lty=3)
	points(Years, ElecUtils.Nuke, pch=6, bg=colorsEU[5])
	lines(Years, ElecUtils.Hydro, col=colorsEU[6], lwd=3)
	lines(Years, ElecUtils.Hydro, lty=3)
	points(Years, ElecUtils.Hydro, pch=21, bg=colorsEU[6])
	lines(Years, ElecUtils.ORenewable, col=colorsEU[7], lwd=3)
	lines(Years, ElecUtils.ORenewable, lty=3)
	points(Years, ElecUtils.ORenewable, pch=22, bg=colorsEU[7])
	lines(Years, ElecUtils.HydroPS, col=colorsEU[8], lwd=3)
	lines(Years, ElecUtils.HydroPS, lty=3)
	points(Years, ElecUtils.HydroPS, pch=23, bg=colorsEU[8])
	lines(Years, ElecUtils.OSources, col=colorsEU[9], lwd=3)
	lines(Years, ElecUtils.OSources, lty=3)
	points(Years, ElecUtils.OSources, pch=24, bg=colorsEU[9])
    box()
```
```{r fig.width=8, fig.height=4.25, echo=FALSE, results='asis'}
	plot(8, 8, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 100), ylim = c(0,100))
	legend("left", inset=.05, title="Source", c("Coal","Petroleum","Natural Gas","Other Gas","Nuclear","Hydroelectric","Other Renewable","Hydroelectric Pumped Storage","Other Sources"), fill=colorsEU, horiz=FALSE)
```

\pagebreak

***Industrial Sector***

---------

1.  The industrial sector saw a drop of `r abs(IndustSect.NGas[11]-IndustSect.NGas[1])` natural gas units over the period from 2003 to 2013.
2.  Other renewable sources increased from `r IndustSect.ORenewable[1]` plants in 2003 to `r IndustSect.ORenewable[11]` plants in 2013.
  
In 2013, there are `r IndustSect.Coal[11]` coal plants, `r IndustSect.Petrol[11]` petroleum plants, `r IndustSect.NGas[11]` natural gas plants, `r IndustSect.Nuke[11]` nuclear power plants, `r IndustSect.Hydro[11]` conventional hydroelectric plants, `r IndustSect.ORenewable[11]` other renewable plants, `r IndustSect.HydroPS[11]` pumped storage hydroelectric plants, and `r IndustSect.OSources[11]` other plants  in operation at electric utilities.  

```{r fig.width=8, fig.height=5.25, echo=FALSE, results='asis'}
# Industrial Sector	
# color pattern is "matlab.like" from colorRamps package
colorsEU <- matlab.like(9)
allIndust <- c(IndustSect.Coal, IndustSect.Petrol, IndustSect.NGas, IndustSect.OGas, IndustSect.Nuke, IndustSect.Hydro, IndustSect.HydroPS, IndustSect.ORenewable, IndustSect.OSources)
maxValue <- max(allIndust)
minValue <- min(allIndust)
    plot(Years, IndustSect.Coal, main="Industrial Sector", xlab = "Year", ylab = "Count of Electric Power Industry Power Plants", 
    type="l", col=colorsEU[1], axes=TRUE, lwd = 3, bty='L',ylim=c(minValue,maxValue))
	lines(Years, IndustSect.Coal, lty=3)
	points(Years, IndustSect.Coal, pch=0, bg=colorsEU[1])
	lines(Years, IndustSect.Petrol, col=colorsEU[2], lwd=3)
	lines(Years, IndustSect.Petrol, lty=3)
	points(Years, IndustSect.Petrol, pch=1, bg=colorsEU[2])
	lines(Years, IndustSect.NGas, col=colorsEU[3], lwd=3)
	lines(Years, IndustSect.NGas, lty=3)
	points(Years, IndustSect.NGas, pch=2, bg=colorsEU[3])
	lines(Years, IndustSect.OGas, col=colorsEU[4], lwd=3)
	lines(Years, IndustSect.OGas, lty=3)
	points(Years, IndustSect.OGas, pch=5, bg=colorsEU[4])
	lines(Years, IndustSect.Nuke, col=colorsEU[5], lwd=3)
	lines(Years, IndustSect.Nuke, lty=3)
	points(Years, IndustSect.Nuke, pch=6, bg=colorsEU[5])
	lines(Years, IndustSect.Hydro, col=colorsEU[6], lwd=3)
	lines(Years, IndustSect.Hydro, lty=3)
	points(Years, IndustSect.Hydro, pch=21, bg=colorsEU[6])
	lines(Years, IndustSect.ORenewable, col=colorsEU[7], lwd=3)
	lines(Years, IndustSect.ORenewable, lty=3)
	points(Years, IndustSect.ORenewable, pch=22, bg=colorsEU[7])
	lines(Years, IndustSect.HydroPS, col=colorsEU[8], lwd=3)
	lines(Years, IndustSect.HydroPS, lty=3)
	points(Years, IndustSect.HydroPS, pch=23, bg=colorsEU[8])
	lines(Years, IndustSect.OSources, col=colorsEU[9], lwd=3)
	lines(Years, IndustSect.OSources, lty=3)
	points(Years, IndustSect.OSources, pch=24, bg=colorsEU[9])
    box()
```
```{r fig.width=8, fig.height=4.25, echo=FALSE, results='asis'}
	plot(8, 8, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 100), ylim = c(0,100))
	legend("left", inset=.05, title="Source", c("Coal","Petroleum","Natural Gas","Other Gas","Nuclear","Hydroelectric","Other Renewable","Hydroelectric Pumped Storage","Other Sources"), fill=colorsEU, horiz=FALSE)
```

\pagebreak


***Commerical Sector***

----------

1.  The number of other renewable plants increased by `r ComSect.ORenewable[11]-ComSect.ORenewable[1]` plants over the period from 
2003 to 2013.
2.  Natural gas plants dropped from 2003 to 2008, then increased to `r ComSect.NGas[11]` in 2013.
3.  There was a small increase in petroleum plants to `r ComSect.ORenewable[11]` in 2013.
  
In 2013, there are `r ComSect.Coal[11]` coal plants, `r ComSect.Petrol[11]` petroleum plants, `r ComSect.NGas[11]` natural gas plants, `r ComSect.Nuke[11]` nuclear power plants, `r ComSect.Hydro[11]` conventional hydroelectric plants, `r ComSect.ORenewable[11]` other renewable plants, `r ComSect.HydroPS[11]` pumped storage hydroelectric plants, and `r ComSect.OSources[11]` other plants  in operation at electric utilities.  

```{r fig.width=8, fig.height=5.25, echo=FALSE, results='asis'}
# Commercial Sector	
# color pattern is "matlab.like" from colorRamps package
colorsEU <- matlab.like(9)
allCom <- c(ComSect.Coal, ComSect.Petrol, ComSect.NGas, ComSect.OGas, ComSect.Nuke, ComSect.Hydro, ComSect.HydroPS, ComSect.ORenewable, ComSect.OSources)
maxValue <- max(allCom)
minValue <- min(allCom)
    plot(Years, ComSect.Coal, main="Commercial Sector", xlab = "Year", ylab = "Count of Electric Power Industry Power Plants", type="l", col=colorsEU[1], axes=TRUE, lwd = 3, bty='L',ylim=c(minValue,maxValue))
	lines(Years, ComSect.Coal, lty=3)
	points(Years, ComSect.Coal, pch=0, bg=colorsEU[1])
	lines(Years, ComSect.Petrol, col=colorsEU[2], lwd=3)
	lines(Years, ComSect.Petrol, lty=3)
	points(Years, ComSect.Petrol, pch=1, bg=colorsEU[2])
	lines(Years, ComSect.NGas, col=colorsEU[3], lwd=3)
	lines(Years, ComSect.NGas, lty=3)
	points(Years, ComSect.NGas, pch=2, bg=colorsEU[3])
	lines(Years, ComSect.OGas, col=colorsEU[4], lwd=3)
	lines(Years, ComSect.OGas, lty=3)
	points(Years, ComSect.OGas, pch=5, bg=colorsEU[4])
	lines(Years, ComSect.Nuke, col=colorsEU[5], lwd=3)
	lines(Years, ComSect.Nuke, lty=3)
	points(Years, ComSect.Nuke, pch=6, bg=colorsEU[5])
	lines(Years, ComSect.Hydro, col=colorsEU[6], lwd=3)
	lines(Years, ComSect.Hydro, lty=3)
	points(Years, ComSect.Hydro, pch=21, bg=colorsEU[6])
	lines(Years, ComSect.ORenewable, col=colorsEU[7], lwd=3)
	lines(Years, ComSect.ORenewable, lty=3)
	points(Years, ComSect.ORenewable, pch=22, bg=colorsEU[7])
	lines(Years, ComSect.HydroPS, col=colorsEU[8], lwd=3)
	lines(Years, ComSect.HydroPS, lty=3)
	points(Years, ComSect.HydroPS, pch=23, bg=colorsEU[8])
	lines(Years, ComSect.OSources, col=colorsEU[9], lwd=3)
	lines(Years, ComSect.OSources, lty=3)
	points(Years, ComSect.OSources, pch=24, bg=colorsEU[9])
    box()
```
```{r fig.width=8, fig.height=4.25, echo=FALSE, results='asis'}
	plot(8, 8, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 100), ylim = c(0,100))
	legend("left", inset=.05, title="Source", c("Coal","Petroleum","Natural Gas","Other Gas","Nuclear","Hydroelectric","Other Renewable","Hydroelectric Pumped Storage","Other Sources"), fill=colorsEU, horiz=FALSE)
```
\pagebreak

***Independent power producers, combined heat and electricity ***

-----------

1.  The number of natural gas plants dropped from `r IndepComb.NGas[1]` in 2003 to `r IndepComb.NGas[11]` in 2013.
2.  There was a small increase in the utilization of other renewable power plant sources to `r IndepComb.ORenewable[11]` in 2013.
3.  There was a small drop in the number of coal power plants.  Over the period from 2003 to 2013, there was an average drop of `r abs((IndepComb.ORenewable[11]-IndepComb.ORenewable[1])/(Years[11]-Years[1]))` per year.  
  
In 2013, there are `r IndepComb.Coal[11]` coal plants, `r IndepComb.Petrol[11]` petroleum plants, `r IndepComb.NGas[11]` natural 
gas plants, `r IndepComb.Nuke[11]` nuclear power plants, `r IndepComb.Hydro[11]` conventional hydroelectric plants, 
`r IndepComb.ORenewable[11]` other renewable plants, `r IndepComb.HydroPS[11]` pumped storage hydroelectric plants, and `r IndepComb.OSources[11]` other plants  in operation at electric utilities.  

```{r fig.width=8, fig.height=5.25, echo=FALSE, results='asis'}
# Independent power producers, combined elec. with heat
# color pattern is "matlab.like" from colorRamps package
colorsEU <- matlab.like(9)
allIndep <- c(IndepComb.Coal, IndepComb.Petrol, IndepComb.NGas, IndepComb.OGas, IndepComb.Nuke, IndepComb.Hydro, IndepComb.HydroPS, IndepComb.ORenewable, IndepComb.OSources)
maxValue <- max(allIndep)
minValue <- min(allIndep)
    plot(Years, IndepComb.Coal, main="Independent Power Producers - Combined Heat and Electricity", xlab = "Year", ylab = "Count of 
  Electric Power Industry Power Plants", type="l", col=colorsEU[1], axes=TRUE, lwd = 3, bty='L',ylim=c(minValue,maxValue))
	lines(Years, IndepComb.Coal, lty=3)
	points(Years, IndepComb.Coal, pch=0, bg=colorsEU[1])
	lines(Years, IndepComb.Petrol, col=colorsEU[2], lwd=3)
	lines(Years, IndepComb.Petrol, lty=3)
	points(Years, IndepComb.Petrol, pch=1, bg=colorsEU[2])
	lines(Years, IndepComb.NGas, col=colorsEU[3], lwd=3)
	lines(Years, IndepComb.NGas, lty=3)
	points(Years, IndepComb.NGas, pch=2, bg=colorsEU[3])
	lines(Years, IndepComb.OGas, col=colorsEU[4], lwd=3)
	lines(Years, IndepComb.OGas, lty=3)
	points(Years, IndepComb.OGas, pch=5, bg=colorsEU[4])
	lines(Years, IndepComb.Nuke, col=colorsEU[5], lwd=3)
	lines(Years, IndepComb.Nuke, lty=3)
	points(Years, IndepComb.Nuke, pch=6, bg=colorsEU[5])
	lines(Years, IndepComb.Hydro, col=colorsEU[6], lwd=3)
	lines(Years, IndepComb.Hydro, lty=3)
	points(Years, IndepComb.Hydro, pch=21, bg=colorsEU[6])
	lines(Years, IndepComb.ORenewable, col=colorsEU[7], lwd=3)
	lines(Years, IndepComb.ORenewable, lty=3)
	points(Years, IndepComb.ORenewable, pch=22, bg=colorsEU[7])
	lines(Years, IndepComb.HydroPS, col=colorsEU[8], lwd=3)
	lines(Years, IndepComb.HydroPS, lty=3)
	points(Years, IndepComb.HydroPS, pch=23, bg=colorsEU[8])
	lines(Years, IndepComb.OSources, col=colorsEU[9], lwd=3)
	lines(Years, IndepComb.OSources, lty=3)
	points(Years, IndepComb.OSources, pch=24, bg=colorsEU[9])
    box()
```
```{r fig.width=8, fig.height=4.25, echo=FALSE, results='asis'}
	plot(8, 8, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 100), ylim = c(0,100))
	legend("left", inset=.05, title="Source", c("Coal","Petroleum","Natural Gas","Other Gas","Nuclear","Hydroelectric","Other Renewable","Hydroelectric Pumped Storage","Other Sources"), fill=colorsEU, horiz=FALSE)
```
\pagebreak

***Independent power producers, not combined ***

---------

1.  Independent power producers (non-combined heat and electricity) utilized a substantial rise of `r IndepNComb.ORenewable[11]-IndepNComb.ORenewable[1]` other renewable-powered plants.  This corresponded to a mean increase of `r abs((IndepNComb.ORenewable[11]-IndepNComb.ORenewable[1])/(Years[11]-Years[1]))` plants per year. 
2.  No other plant sources showed a substantial change.
  
In 2013, there are `r IndepNComb.Coal[11]` coal plants, `r IndepNComb.Petrol[11]` petroleum plants, `r IndepNComb.NGas[11]` natural 
gas plants, `r IndepNComb.Nuke[11]` nuclear power plants, `r IndepNComb.Hydro[11]` conventional hydroelectric plants, `r IndepNComb.ORenewable[11]` other renewable plants, `r IndepNComb.HydroPS[11]` pumped storage hydroelectric plants, and `r IndepNComb.OSources[11]` other plants  in operation at electric utilities.  

```{r fig.width=8, fig.height=5.25, echo=FALSE, results='asis'}
# Independent power producers, combined elec. with heat
# color pattern is "matlab.like" from colorRamps package
colorsEU <- matlab.like(9)
allIndepN <- c(IndepNComb.Coal, IndepNComb.Petrol, IndepNComb.NGas, IndepNComb.OGas, IndepNComb.Nuke, IndepNComb.Hydro, IndepNComb.HydroPS, IndepNComb.ORenewable, IndepNComb.OSources)
maxValue <- max(allIndepN)
minValue <- min(allIndepN)
    plot(Years, IndepNComb.Coal, main="Independent Power Producers - Heat and Electricity Separate", xlab = "Year", ylab = "Count of 
  Electric Power Industry Power Plants", type="l", col=colorsEU[1], axes=TRUE, lwd = 3, bty='L',ylim=c(minValue,maxValue))
	lines(Years, IndepNComb.Coal, lty=3)
	points(Years, IndepNComb.Coal, pch=0, bg=colorsEU[1])
	lines(Years, IndepNComb.Petrol, col=colorsEU[2], lwd=3)
	lines(Years, IndepNComb.Petrol, lty=3)
	points(Years, IndepNComb.Petrol, pch=1, bg=colorsEU[2])
	lines(Years, IndepNComb.NGas, col=colorsEU[3], lwd=3)
	lines(Years, IndepNComb.NGas, lty=3)
	points(Years, IndepNComb.NGas, pch=2, bg=colorsEU[3])
	lines(Years, IndepNComb.OGas, col=colorsEU[4], lwd=3)
	lines(Years, IndepNComb.OGas, lty=3)
	points(Years, IndepNComb.OGas, pch=5, bg=colorsEU[4])
	lines(Years, IndepNComb.Nuke, col=colorsEU[5], lwd=3)
	lines(Years, IndepNComb.Nuke, lty=3)
	points(Years, IndepNComb.Nuke, pch=6, bg=colorsEU[5])
	lines(Years, IndepNComb.Hydro, col=colorsEU[6], lwd=3)
	lines(Years, IndepNComb.Hydro, lty=3)
	points(Years, IndepNComb.Hydro, pch=21, bg=colorsEU[6])
	lines(Years, IndepNComb.ORenewable, col=colorsEU[7], lwd=3)
	lines(Years, IndepNComb.ORenewable, lty=3)
	points(Years, IndepNComb.ORenewable, pch=22, bg=colorsEU[7])
	lines(Years, IndepNComb.HydroPS, col=colorsEU[8], lwd=3)
	lines(Years, IndepNComb.HydroPS, lty=3)
	points(Years, IndepNComb.HydroPS, pch=23, bg=colorsEU[8])
	lines(Years, IndepNComb.OSources, col=colorsEU[9], lwd=3)
	lines(Years, IndepNComb.OSources, lty=3)
	points(Years, IndepNComb.OSources, pch=24, bg=colorsEU[9])
    box()
```
```{r fig.width=8, fig.height=4.25, echo=FALSE, results='asis'}
	plot(8, 8, type="n", axes=FALSE, ann=FALSE, xlim=c(0, 100), ylim = c(0,100))
	legend("left", inset=.05, title="Source", c("Coal","Petroleum","Natural Gas","Other Gas","Nuclear","Hydroelectric","Other Renewable","Hydroelectric Pumped Storage","Other Sources"), fill=colorsEU, horiz=FALSE)
```

Links to datasets and Markdown code.
All Sectors dataset
Coal dataset
Commerical Sector dataset
Independent Combined dataset
Independent Noncombined dataset
Industrial Sector dataset
ElectricPowerIndustryPlants.Rmd file
Rmd file rendered as PDF
Depending on your browser you may have to 'save as.'

Some places to find out more:

  1. LaTeX installation: Obtaining LaTeX at latex-project.org
  2. The main Markdown site: R Markdown. The assumption is generally that you will be using R Studio. You can run Markdown in the regular R GUI without any complication. I can't use R Studio at work because of security restrictions but can use Markdown anyway.
  3. Pandoc is required for running Markdown. See http://pandoc.org/
  4. A great R resource! See: "R In Action" from Manning.com It is worth a little extra to get the second edition. (Markdown isn't even covered in the first edition.) I highly recommend this book.

Contact me: