You don't provide much at all in the way of sample data to really give us an idea of what you want to achieve, but here's something that might get you started. Ultimately, what the recommendation comes down to is to convert your data to "xts" and use period.apply
to aggregate and plot your data at "arbitrary" time frames.
Here's some sample data, first as a data.frame
of random values collected every 11 minutes starting at 2012-10-22 12:10:21 EDT, then converted to xts
:
set.seed(1)
temp <- data.frame(date = seq(as.POSIXct("2012-10-22 12:10:21 EDT", tz="EDT"),
length.out = 100, by = "11 min"),
values = rnorm(100))
library(xts)
x.temp <- xts(temp[-1], temp[, 1])
head(x.temp)
# values
# 2012-10-22 12:10:21 -0.6264538
# 2012-10-22 12:21:21 0.1836433
# 2012-10-22 12:32:21 -0.8356286
# 2012-10-22 12:43:21 1.5952808
# 2012-10-22 12:54:21 0.3295078
# 2012-10-22 13:05:21 -0.8204684
Here, we're going to aggregate, arbitrarily, the sum for every 93 minutes that elapsed.
my93minAgg <- period.apply(x.temp,
INDEX = endpoints(x.temp, on = "mins", k = 93),
FUN = sum)
my93minAgg
# values
# 2012-10-22 13:16:21 0.3133101
# 2012-10-22 14:55:21 1.1543989
# 2012-10-22 16:23:21 2.1290954
# 2012-10-22 18:02:21 0.5205041
# 2012-10-22 19:30:21 -0.6007850
# 2012-10-22 21:09:21 1.5058904
# 2012-10-22 22:37:21 0.9999036
# 2012-10-23 00:16:21 1.1553448
# 2012-10-23 01:44:21 1.9799783
# 2012-10-23 03:23:21 -1.7152471
# 2012-10-23 04:51:21 2.9882778
# 2012-10-23 06:19:21 0.4580653
Here's how you would plot it:
plot(my93minAgg, main = "My 93 Minute Aggregation")