I would like to group by and take the sum of the observations by time intervals of 10 minutes in R.
I have looked into cut
, and to.period
from the xts
package and requires OHLC
data (Open High Low Close stock data) - I have a different time series data set.
Python code:
data_timeidx = data.set_index('timestamp')
data_time_grp = data_timeidx.groupby(pd.Grouper(freq='10Min'))
Data:
start <- as.POSIXct("2015-12-05 06:00:00", "%Y-%m-%d %H:%M")
end <- as.POSIXct("2015-12-05 08:00:00", "%Y-%m-%d %H:%M")
time <- seq(start, end, by = 0.05)
d <- data.frame(time)
obs <- nrow(d)
d$data <- rnorm(obs)