##################################################################################
# A script to read in the Chicago climate data between 2001 to mid-2013 and
# histogram the January and July temperatures.
#
# Author: S Towers
#
# Created: Sept 5, 2013
#
# This script is not guaranteed to be free of bugs and/or errors.
#
# This script can be freely used and shared as long as the author and
# copyright information in this header remain intact.
##################################################################################
require("sfsmisc")
wdat=read.table("chicago_weather_summary.txt",header=T)
adat = subset(wdat,month==7)
bdat = subset(wdat,month==1)
mult.fig(1)
breaks = seq(-10,100,by=5)
a=hist(bdat$temperature,breaks=breaks,xlim=c(-10,100),ylim=c(0,150),col=4,ylab="\043 per 5 deg bin",xlab="Temp (F)",main="January and July temperatures in Chicago, 2001 to 2013")
hist(adat$temperature,breaks=breaks,xlim=c(-10,100),add=T,col=2)
legend("topleft",legend=c("January","July"),col=c(4,2),lwd=5,bty="n")
x = bdat$temperature
cat("\n")
cat("The number of January temperature observations 2001 to 2013 is ",length(x),"\n")
cat("The mean of January temperature data is ",mean(x),sum(x)/length(x),"\n")
avar = (1/(length(x)-1))*sum((x-mean(x))^2)
cat("The variance of January temperature data is ",var(x),avar,"\n")
cat("The standard deviation of the January temperature data is ",sd(x),"\n")
cat("\n")
x = adat$temperature
cat("The number of July temperature observations 2001 to 2013 is ",length(x),"\n")
cat("The mean of July temperature data is ",mean(x),sum(x)/length(x),"\n")
avar = (1/(length(x)-1))*sum((x-mean(x))^2)
cat("The variance of July temperature data is ",var(x),avar,"\n")
cat("The standard deviation of the July temperature data is ",sd(x),"\n")
cat("\n")