# Step chart of NASA GISS annual temperature anomaly (C) data ## STEP 1: SETUP setwd('C:/R_Home/Charts & Graphs Blog/GISS_Temp_Anom/') link = c("GISS_Temp.txt") # STEP 2: READ DATA my_Data <- read.table(link, skip = 0, sep = "", dec=".", row.names = NULL, header = FALSE, colClasses <- rep("numeric",3), comment.char = "#", na.strings = c("*", "-",-99.9, -999.9), col.names <- c("Yr", "Ann_Anomaly", "5_Yr_Mean") ) # STEP 3: MANIPULATE DATA # Construct chart title - use 2 lines w/ \n Title <- paste("Annual Surface Air Temperature Anomaly \n Based on Meterologic Stations (1880 - 2007)" ) ## STEP 4: CREATE PLOT par(las = 1) # Sets Y axis label orientation to vertical, set text font sizes par(cex.main=0.8); par(cex.sub=0.7); par(cex.lab = 0.8); par(cex.axis =.75) plot(Ann_Anomaly ~ Yr, my_Data, ylim = c(-1,1), type=c("s"), col = "dark grey", xlab = "", asp = "full", ylab = expression(paste("Annual Temperature Anomaly - ",degree, "C (Baseline: 1951-1980)")), main = Title, sub = "Source: NASA - GISS @ http://data.giss.nasa.gov/gistemp/graphs/Fig.A.txt") lines(lowess(my_Data$Ann_Anomaly ~ my_Data$Yr, f=0.15),col = "blue" ) arrows(1951,-.5, 1980, -.5, code = 3, angle = 20, col = "dark grey") abline(h=0, col = "grey") # o.o horizontal line text(1965, -.495, "Baseline\n Period\n1951-1980", cex = 0.6, pos=3) text(1910, -0.95, "Lowess smoother fit, f = 0.15", cex =0.65, pos = 1 ) points(c(1881,1890), c(-1,-1), col="blue", type = "l")