I'm trying to manually compute variance within matrices in R and I'm having some issues in that I'm getting the incorrect number of dimensions.
I have x, a 12x250 matrix, Temp.means, a 12x1 matrix, and I'm feeding it unto a function with a for look inside.
I would basically like the variance of x so I'm using the apply function to try to apply my variance function to my code... but something is working wrong.
Here is my code:
Variance.fun <- function(x,Temp.means) {
for (i in 1:250) {
vari <- (matrix(x[i,]-Temp.means)^2)/250
}
}