[R] sum of grouped elements of vector

Kathryn Lord kathryn.lord2000 at gmail.com
Fri Jan 23 09:45:48 CET 2015


Dear R users,

I have a quick quesiton.

Here is a vector "a".

a<- c(1,2,3,4,5,6,7,8).

(In fact, I have a huge vector.)


With "a", I'd like to create new vectors, for example,

new1 = (1+2, 3, 4+5+6, 7+8)
new2 = (1, 2+3+4+5+6+7, 8)
new3 = (1+2+3+4+5+6+7, 8)


How could I make the above vectors using R?


Any suggestion will be greatly appreciated.

Best,

Kathryn Lord

	[[alternative HTML version deleted]]



More information about the R-help mailing list