[R] Sum upto every twelth cell in a column
JS Huang
js.huang at protective.com
Mon Mar 2 23:40:29 CET 2015
Here is an implementation.
> (x <-
> c(23,35,22,11,10,1,14,15,13,15,17,16,154,13,24,25,25,25,25,25,22,11,15,15))
[1] 23 35 22 11 10 1 14 15 13 15 17 16 154 13 24 25 25 25
25 25 22 11 15 15
> (y <- c(0,cumsum(x)))
[1] 0 23 58 80 91 101 102 116 131 144 159 176 192 346 359 383 408 433
458 483 508 530 541 556
[25] 571
> (y[seq(13,length(y),12)] - y[seq(1,length(y)-12,12)])
[1] 192 379
--
View this message in context: http://r.789695.n4.nabble.com/Sum-upto-every-twelth-cell-in-a-column-tp4704007p4704087.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list