Skip to content

Instantly share code, notes, and snippets.

/ne_climate.R
Created Jun 30, 2010

Embed
What would you like to do?
Replicating NE climate analysis
# Attempting to replicate analysis in:
# http://wattsupwiththat.com/2010/06/29/waxman-malarkey-impact-zone-us-northeast/
# Data import and cleanup
# Note that 2010 is excluded due to missing values
dat <- read.table("~/Desktop/drd964x.tmpst.txt", colClasses=c("character",rep("numeric", 12)))
dat$year <- as.numeric(substr(dat[,1], 7, 10))
dat <- dat[dat$year < 2010,]
dat$region <- substr(dat$V1, 1, 3)
dat$annual <- apply(dat[,2:13], 1, mean)
dat.ne <- dat[dat$region == "101",]
# Regression for Northeast region, annual mean
print(summary(lm(annual ~ year, data=dat.ne)))
# Regression for Northeast region, annual mean, 1970--2009
print(summary(lm(annual ~ year, data=dat.ne, subset=(year > 1969))))
# Ugliest possible way to average previous year's December
# and current year's January and February
dat.ne$last.dec <- (c(0,dat.ne[,13]))[1:115]
dat.ne <- dat.ne[dat.ne$year > 1895,]
dat.ne$winter <- (dat.ne[,2] + dat.ne[,3] + dat.ne$last.dec) / 3
# Regression for Northeast region, Winter mean
print(summary(lm(winter ~ year, data=dat.ne)))
# Regression for Northeast region, Winter mean, 1970--2009
print(summary(lm(winter ~ year, data=dat.ne, subset=(year > 1969))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.