I have a file with date/time data and its measured values for said date and time. The values were measured every ten minutes for the course of one month, and I am attempting to do a time series analysis eventually. Before that however, I wanted to aggregate the 10 minute intervals to hourly intervals by calculating the mean measurement of every 60 minutes. Here is a sample of my data(a total of 4319 observations):
Date/Time Value
2013-01-01 00:00:00 31,439999
2013-01-01 00:10:00 33,439999
2013-01-01 00:20:00 39
2013-01-01 00:30:00 35,279999
2013-01-01 00:40:00 37,279999
2013-01-01 00:50:00 32,199997
2013-01-01 01:00:00 35,279999
2013-01-01 01:10:00 38,199997
My date/time data is of the type POSIXlt and the values measured are of the type factor. I have searched on this site and I have found several topics posted by other users but they do not all apply to me, or I can not recreate the same results using suggestions given on their posts.
For example, another user asked almost the exact same question as me: Aggregate values of 15 minute steps to values of hourly steps and I followed exactly the steps that their answers provided.
library(xts)
dat.xts <- xts(data$values,
as.POSIXct(data$datetime))
hourly.apply(dat.xts,mean)
but for the last line I get the following error message:
Error: could not find function "hourly.apply"
Although I did already install the xts package as well as the zoo package, which the hourly.apply function appears to stem from. What could be the reason for this? Thank you in advance.
AC11
, I couldn't find "hourly.apply" using ?RSiteSearch. Did you triedperiod.apply
? – akrun