I'm new to R.
I'm trying to calculate the mean and variance of a vector.
However rather than simply calculating the mean and variance of the whole vector, I am trying to calculate the mean and variance of each "block of 10 elements".
For example
v <- c(1:100)
mean(v) # returns 50.5
var(v) # returns 841.6667
what I actually want is a new vector, with length 10, containing this:
mean(v[1:10]), mean(v[11:20]), ... , mean(v[91:100])
(and also the variance)
var(v[1:10]), var(v[11:20]), ... , var(v[91:100])
However I don't know how to accomplish this in a sensible way. Any help appreciated even if that is "go read this reference at [url]". I tried duckduckgo searching for this, but to no avail.
Seems like something that should be easy?