## Population data from: ## http://en.wikipedia.org/wiki/Demographic_history_of_the_United_States population <- read.table("pop.csv",header=T) population$Date <- as.Date(ISOdate(population$year,6,15)) popspline <- splinefun(population$Date,population$uspop) ## Gas prices from: http://www.randomuseless.info/gasprice/usa.txt gasprice <- read.table("usa_gasprice.txt",header=T) gasprice$Date <- as.Date(strptime(as.character(gasprice$Date),"%m/%d/%Y")) gasspline <- splinefun(gasprice$Date,gasprice$NomDollars) ## GDP data from: http://www.bea.gov/national/xls/gdplev.xls gdp <- read.csv("gdp.txt",header=T) gdp <- gdp[1:79,1:3] gdpspline <- splinefun(as.Date(ISOdate(gdp$Year,6,15)),gdp$BilCur) dates <- seq.Date(as.Date("1981/01/01"),as.Date("2008/06/01"),by="month") png("gasanalyzed.png") plot(dates,10*50*gasspline(dates)/(gdpspline(dates)*1e9/popspline(dates)),type="l",ylab="500 USGals gas as fraction of GDP/capita",xlab="Year",main="Cost of Commuting through time") now <-as.Date("2008-06-15") points(now,4.50*10*50/(gdpspline(now)*1e9/popspline(now))) dev.off();