########################################################################### ### Graph of World Oil Production and two Models based on recoverable oil ### Models were found using solver in Excel - see the Excel file ### To find a mode useing R use the nls() function. ### See the wind files in calculus project to get started. ### Produced by Thomas J. Pfaff for sustainabilitymath.org ### March 2023 ########################################################################### ## URL for the data from sustainabilitymath.org dataURL<-"https://sustainabilitymath.org/excel/InvestigatingWorldPeakOil-R.csv" ## Read data from online csv file Oil.data <-read.csv(url(dataURL),header=TRUE) names(Oil.data) ## Define varialbes mostly to save typing x<-Oil.data$Year y1<-Oil.data$World.Thousand.Barrels.per.Year y2<-Oil.data$Model1 y3<-Oil.data$Model2 ######################################## ###### Graphs for Word Document ######## ######################################## ## Define some graphing parameters d<-1.25 #dot size 2.25 for webgraph, 1.25 for document l<-2 #line width 5 for webgraph, 2 for document ## Create graph of Model 1 windows(width=7,height=7) plot(x, y1 ,type="p", cex=d, pch=10, xlim=c(1850,2050), ylim=c(0,30000000), xlab="Year", ylab="Thousand Barrels") title(main="World Oil Production") grid (NULL,NULL, lty = 6, col = "gray") lines(x, y2, xlim=c(1850,2050),col="red", lwd=l) v3<-c("Data", "Model") legend("topleft", v3, pch=c(10,NA_integer_ ), lty=c(0,1), col=c("black","red"), y.intersp=1.25) mtext("Thomas J. Pfaff || sustainabilitymath.org",1,4,adj=1) ## Create graph of Model 2 windows(width=7,height=7) plot(x, y1 ,type="p", cex=d, pch=10, xlim=c(1850,2050), ylim=c(0,30000000), xlab="Year", ylab="Thousand Barrels") title(main="World Oil Production") grid (NULL,NULL, lty = 6, col = "gray") lines(x, y3, xlim=c(1850,2050), col="blue", lwd=l) v3<-c("Data", "Model") legend("topleft", v3, pch=c(10,NA_integer_ ), lty=c(0,1), col=c("black","blue"), y.intersp=1.25) mtext("Thomas J. Pfaff || sustainabilitymath.org",1,4,adj=1) ######################################## ###### Graphs for Web Document ######## ######################################## ## Define some graphing parameters d<-2.25 #dot size 2.25 for webgraph, 1.25 for document l<-5 #line width 5 for webgraph, 2 for document # All three on same graph for web windows(width=7,height=7) par(bg = "#b3c0d7") plot(x, y1 ,type="p", cex=d, pch=10, xlim=c(1850,2050), ylim=c(0,30000000), xlab="Year", ylab="Thousand Barrels") title(main="World Oil Production") lines(x, y2, xlim=c(1850,2050),col="red", lwd=l) lines(x, y3, xlim=c(1850,2050),col="blue", lwd=l) v3<-c("Data", "Model: 2.5 Mbbl Recoverable", "Model: 3.0 Mbbl Recoverable" ) legend("topleft", v3, pch=c(10,NA_integer_,NA_integer_ ), lty=c(0,1,1), col=c("black","red","blue"), y.intersp=1.25)