I am dealing with a dataframe in R that has only 2 columns but a very large number of rows. I want to divide my dataframe into subsets of say 'm' rows each and find the mean of the values in a column for each of these m rows for each division of the dataframe and then return these mean values for all the divisions containing 'm' rows each.
Say my data frame is y with columns 'a' and 'b' and i want 'm' as 1000 in this case.
I want to find mean(y[i:i+999,2])
I would want to take the value of i over all the rows and return the mean values for, in this case each block of 1000 values in column 'b'
i=1
add=function(i,999){i=i+999}
z=return(i)
p=mean(y[z,2])
I think I am doing it wrong. Any insights ?