r - Annual, monthly or daily mean for irregular time series -


i new user of "r", , couldn't find solution solve it. got timeseries in following format:

>dates  temperature depth   salinity >12/03/2012 11:26   9.7533  0.48073 37.607 >12/03/2012 11:56   9.6673  0.33281 37.662 >12/03/2012 12:26   9.6673  0.33281 37.672 

i have irregular frequency variable measurements, done every 15 or every 30 minutes depending on period. calculate annual, monthly , daily averages each of variables, whatever number of data in day/month/year is. read lot of things packages zoo, timeseries, xts, etc. can't clear vision of nead (maybe cause i'm not skilled enough r...).

i hope post clear, don't hesitate tell me if it's not.

convert data xts object, use apply.daily et al calculate whatever values want.

library(xts) d <- structure(list(dates = c("12/03/2012 11:26", "12/03/2012 11:56",  "12/03/2012 12:26"), temperature = c(9.7533, 9.6673, 9.6673),      depth = c(0.48073, 0.33281, 0.33281), salinity = c(37.607,      37.662, 37.672)), .names = c("dates", "temperature", "depth",  "salinity"), row.names = c(na, -3l), class = "data.frame") x <- xts(d[,-1], as.posixct(d[,1], format="%m/%d/%y %h:%m")) apply.daily(x, colmeans) #                     temperature     depth salinity # 2012-12-03 12:26:00    9.695967 0.3821167   37.647 

Comments