Hi Alexandra, This produces a rather messy plot, but it might get you started:
finalData<-data.frame(ws=sample(0:100,1300,TRUE), stn=rep(1:13,each=100),hour=rep(1:24,length.out=1300)) statHour = tapply(finalData$ws,list(finalData$stn,finalData$hour),sd) # open a wide device x11(width=13) # leave room for an external legend par(mar=c(5,4,4,6)) matplot(1:24,t(statHour),type="b", main="Wind speed standard deviation by hour of day", xlab="Hour",ylab="Wind speed standard deviation",lty=1) legend(25.2,40,legend=paste("Stn",1:13,sep=""),pch=c(0:9,"a","b","c"), col=1:13,xpd=TRUE) Jim On Tue, Mar 31, 2015 at 10:07 AM, Alexandra Catena <amc5...@gmail.com> wrote: > Hello, > > I am trying to plot the hourly standard deviation of wind speeds from > 13 different measured locations over many years. I imported the data > using readLines and into a dataframe called finalData. Using tapply, I > determined the standard deviation of the windspeed (ws) for each hour > (hour) from every location (stn) using this command line: > > statHour = tapply(finalData$ws,list(finalData$stn,finalData$hour),sd) > > I want to plot the standard deviation for each hour of the day, with > hours as the x-axis and the standard deviation for the y-axis, and > each station as a different color. I've managed to get a boxplot of > this, but ideally, I'd like a scatter plot to determine the variations > between each instrument throughout the day. The boxplot command is > this: > > boxplot(statHour, names=colnames(statHour),xlab='Hour of the > Day',ylab='Standard Deviation of Wind Speed') > > I also tried to make a dataframe of the tapply output but it ends up > using the hours as the column names instead of putting it into the > dataframe. Please help!! > > I have R version 3.1.1 > > Thanks a lot, > Alexandra > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.