#Read in data (the three lines with Northern, Southern, Global have already been removed) EAno <- read.table("/Users/antonyunwin/Desktop/EAno.txt",header=F,sep="",quote="") #Give variable names to the columns colnames(EAno)<-c("Year","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Ave") #Add a column for the area Area<-rep(c("N","S","G"),rep(141,3)) #EAnoAll is a dataset with variables for each month and the three regions in the same variable EAnoAll<-cbind(Area,EAno) #Reshape the data so that there is one line for each year #EAlines is a dataset with separate columns for each of the regions EAlines<-cbind(EAnoAll[1:141,],EAnoAll[142:282,-c(1,2)],EAnoAll[283:423,-c(1,2)]) dim(EAlines) #Transpose the data EAnew<-t(EAlines[,3:41]) #Add variable names colnames(EAnew)<-seq(1856,1996) #Add information for the rows Region<-rep(c("N","S","G"),rep(13,3)) Month<-rep(c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Ave"),3) EAnew<-cbind(Region,Month,EAnew) #EAnew has one variable for each year and coding variables for region and month EAnew<-as.data.frame(EAnew)