I have a data frame with 84 rows and 48 columns and want to calculate for each 4 consecutive columns at every each 7 rows the following statistics: sum sum min max each corresponding to a column, and then jump to the other 4 columns of the 48 columns of the data.frame.
I have found a StackOverflow post already, but it didn't work for all my data.frame. It just worked for each column and it only does one statistics per time per column.
v=dataset$count
n = 7
sidx = seq.int(from=1, to=length(v), by=n)
eidx = c((sidx-1)[2:length(sidx)], length(v))
thesum = sapply(1:length(sidx), function(i) sum(v[sidx[i]:eidx[i]]))
thesum
[1] 10957 10955 10953 10955 10954 10955 10957 10956 10958 10953 10954 10956