I have a 320*25 matrix that I want to transform into a 64*25 matrix in this way: each row of the new matrix should have the averages of every 5 rows of the old one (and then they will be normalized by a certain vector in a similar way). Below you can see how I’ve been trying to implement this:
for (x in c(1:64)){
helping.matrix[x,] = colSums(original.matrix[((5*(x-1)+1):5*x),])/sum(vector[((5*(x- 1)+1):5*x)])
}
Unfortunately this didn’t work, returning the following error:
Error in inherits(x, “data.frame”) : subscript out of bounds
Well, this might do it – if you have numeric values without NA:s…