30 January 2013

China's primary energy

I have made a chart showing the trend in China's primary energy production and consumption.

I got the raw data from International Energy Statistics part of the US Energy Information Administration webpage. I downloaded two sets of time series data, production and cosumption, from 1980 to 2011 as Excel spreadsheets. I opened each sheet with a spreadsheet program (Gnumeric) and saved each file as a comma separated values file. I then opened each CSV file with a text editor and copied the numbers separated by commas into the script sheet of Rkward, the script editor I use with R.

That made it easy to read the data into R

China Total Primary Energy Consumption (Quadrillion Btu)

Being American, the data is expressed in the bizarre unit Quadrillion British thermal units (BTU) WTF? It's the amount of energy needed to heat one pound of water by one degree Fahrenheit. Not even the British use the BTU. The conversion factor to joules is 1 Quadrillion BTU = 1055 × 10^15 joules.

#num [1:30] 1.82e+19 1.81e+19 1.89e+19 2.01e+19 2.16e+19 ...(telling us the data is a numeric R object, consisting of 30 numbers )
#[1] 9.522205e+19 (the maximum number in the data series is 9.522205 x 10^19)
ejc<-c(jc/10^18) #convert data from joules to exajoules
[1] 95.22205
p<-c(18.12198,17.9451,18.92106,20.2361,22.12683,24.30279,25.04091,25.93877,27.14594,28.77554,29.38537,29.62193,30.32492,31.97204,34.13204,35.04591,35.668,37.81456,36.38594,34.99918,34.19953,37.5048,42.8456,49.44335,59.38067,64.44807,66.78499,70.841,78.34819,81.88698) #China Total Primary Energy Production
Year<-c(1980:2009) # need a time integer
png("China-primary-energy-ej-2009v1.png", width=650, height=500, pointsize = 16)
plot(Year,ejc,las=1,ylim=c(0,95),type="n",cex.main=1.6, cex.lab=1.2, main="China Total Primary Energy 1980 to 2009",xlab="Year", ylab="exajoules (10^18 joules)")
mtext(side=1,line=-2,"Data: US EIA")
legend("top",bty='n',bg="white", c("Energy consumption","Energy production"),lty = 1,lwd=3,col = c(2,4))

Give that a go!

No comments :

Post a Comment