Dear All-

I have a dataset that is comprised of the following (LST = yymmddhhMM):



LST in mph Deg DegF DegF2 % volts Deg mph2 w/m2 0509010000 0.00 7.8 216.9 45.1 -999 24.4 -999 -999 10.6 0.2 0509010005 0.00 8.6 206.6 45.1 -999 25.2 -999 -999 11.7 0.2 0509010010 0.00 7.8 199.2 44.9 -999 25.4 -999 -999 12.8 0.2 0509010015 0.00 7.7 197.4 44.8 -999 25.4 -999 -999 10.4 0.2 0509010020 0.00 7.6 203.9 44.8 -999 25.3 -999 -999 10.0 0.2 0509010025 0.00 9.3 200.9 44.9 -999 25.3 -999 -999 11.8 0.2 0509010030 0.00 9.4 200.3 44.7 -999 25.5 -999 -999 12.2 0.2 0509010035 0.00 10.0 199.2 44.6 -999 25.9 -999 -999 13.0 0.2 0509010040 0.00 9.5 201.5 44.5 -999 25.9 -999 -999 13.3 0.2 0509010045 0.00 10.8 200.4 44.5 -999 26.1 -999 -999 13.0 0.2 0509010050 0.00 11.8 198.4 44.5 -999 26.1 -999 -999 13.3 0.2 0509010055 0.00 11.0 197.4 44.5 -999 25.5 -999 -999 13.3 0.2 0509010100 0.00 9.7 202.0 44.6 -999 25.1 -999 -999 13.0 0.2 0509010105 0.00 9.0 215.1 44.7 -999 24.9 -999 -999 12.2 0.2 0509010110 0.00 10.1 223.1 44.6 -999 25.1 -999 -999 13.2 0.2 0509010115 0.00 10.4 231.2 44.5 -999 25.5 -999 -999 12.0 0.2 0509010120 0.00 11.0 237.4 44.2 -999 25.9 -999 -999 11.7 0.2 0509010125 0.00 10.6 241.0 44.2 -999 26.0 -999 -999 11.8 0.2 0509010130 0.00 11.1 242.2 44.1 -999 26.2 -999 -999 12.2 0.2 0509010135 0.00 10.6 240.0 44.0 -999 26.5 -999 -999 11.5 0.2 0509010140 0.00 10.1 241.0 44.0 -999 26.4 -999 -999 11.5 0.2 0509010145 0.00 9.8 243.2 44.0 -999 26.6 -999 -999 10.7 0.2 0509010150 0.00 9.3 240.3 43.9 -999 27.0 -999 -999 10.0 0.2 0509010155 0.00 9.3 239.2 43.8 -999 26.8 -999 -999 10.0 0.2 0509010200 0.00 9.2 240.1 43.8 -999 26.6 -999 -999 9.8 0.2 0509010205 0.00 9.0 240.0 43.8 -999 26.6 -999 -999 9.4 0.2 0509010210 0.00 9.2 245.0 43.9 -999 26.3 -999 -999 9.8 0.2 0509010215 0.00 9.4 253.2 44.1 -999 26.4 -999 -999 10.6 0.2

The data are recorded in 5 minute intervals and I would like to condense it into hourly means for "mph". For example, I would like the hourly avg of mph so that the output would be as follows:

Year Month Day Hour mph
2005 1 1 0 12
2005 1 1 1 7
2005 1 1 2 11, etc.


It seems I am able to get the averages but not output the corresponding date/time stamp. From looking at previous help questions, I think I need to us "ts" and "aggregate". Gabor taught me how to convert the date/time stamp to an easier to manage format (his help is shown below). This is what I have so far.
library(zoo)
library(chron)

z <- read.zoo("SPL 2005 2008 met data 5 min wout full hdr.txt", header = TRUE, na.strings = -999,
format = "%y%m%d%H%M", FUN = as.chron,
colClasses = c("character", rep("numeric", 10))) z.ts <- ts(z, frequency=12) #avging 5 min intervals to get hourly avg. ww <- matrix(aggregate(z.ts[,2], FUN=mean))

any thoughts as to how to add the time stamp is greatly welcomed!

sherri heck

______________________________________________
[email protected] mailing list
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.

Reply via email to