I have the following R code:
n = 10
t = 5
N = n * t
x <- rnorm(N)
I want to calculate the mean for every t observations. That is:
mean(x[1:5])
mean(x[6:10])
.
.
mean(x[46:50])
Similarly,
mean(x[c(1,11,21,31,41)])
mean(x[c(2,12,22,32,42)])
.
.
mean(x[c(10,20,30,40,50)])
How can I do that in a simple way?
Your help is appreciated.