[R] Plotting using tapply function output

Jim Lemon drjimlemon at gmail.com
Tue Mar 31 04:10:00 CEST 2015

Hi Alexandra,
This produces a rather messy plot, but it might get you started:

statHour = tapply(finalData$ws,list(finalData$stn,finalData$hour),sd)
# open a wide device
# leave room for an external legend
 main="Wind speed standard deviation by hour of day",
 xlab="Hour",ylab="Wind speed standard deviation",lty=1)


On Tue, Mar 31, 2015 at 10:07 AM, Alexandra Catena <amc5981 at gmail.com>

> 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 at 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]]

More information about the R-help mailing list