I have a vector and I need to sum every n numbers and return the results. This is the way I plan on doing it currently. Any better way to do this?
n
v <- 1:100 n <- 10 cutpoints <- seq( 1 , length( v ) , by = n ) categories <- findInterval( 1:length( v ) , cutpoints ) tapply( v , categories , sum )