Skip to content
Prev 312687 / 398506 Next

How to calculate mean of every nth time series data with zoo or xts ?

Hello,

You should include a data example, using ?dput.
Anyway, making up some data,


t1 <- as.POSIXct("2012-1-1 0:0:0")
t2 <- as.POSIXct("2012-1-4 0:0:0")
d <- seq(t1, t2, by = "1 min")
x <- rnorm(length(d))

z <- zoo(x, d)

aggregate(z, list(format(index(z), "%H:%M")), FUN = mean)


Hope this helps,

Rui Barradas
Em 02-12-2012 18:09, ??? escreveu: