giss = read.csv("giss_temp.csv")
allyears = unique(giss$Year)
ann_temp = tapply(giss$TempAnom, giss$Year, mean)
mycols = ifelse(allyears > 1980, "violet", "brown")
plot(allyears, ann_temp, type = 'h',
col = mycols, lwd = 3,
xlab= "Year", ylab = "T Anomaly", main="T Anomaly pre/post 1980")
legend("topleft",pch = 15,cex=0.8,col = c("brown","violet"),legend = c("pre 1980","post 1980"), title="Legend")Module 6
Quarto of Module 5
Part A
In this module we initially made a loop to plot select time series by month. The code below modifies this loop so that it loops across all years instead of months, and plots the 12 monthly time values for each year.
giss = read.csv("giss_temp.csv")
for (i in 1881:2011) {
yearID = which(giss$Year == i)
plot(giss$Month[yearID], giss$TempAnom[yearID],
xlab="Month", xlim = c(1,12), ylab="Temperature Anomaly", ylim=c(-1,1), main=paste("Temp. Anom.",i))
}Part B
Generates a vector of colors dependent on whether the year is prior to 1980, or after 1980.