Skip to content
Prev 303065 / 398503 Next

summarize a vector

On Aug 10, 2012, at 12:20 PM, Sam Steingold wrote:

            
Well, using v with parentheses instead of square-brackets might not be  
the right way, since v is not a function.

Consider this alternate (no need to pre-allocate 'w'):

 > w <- tapply( v ,rep(1:(N/k +1), each=k, len=N ) , sum)
 > w
  1  2  3  4
  6 15 24 10