[R] sum of grouped elements of vector
gunter.berton at gene.com
Fri Jan 23 10:32:12 CET 2015
If Jim's answer is not what you want, then I would say it is because
your question is too vague to be answered. In particular, how do you
specify the elements of the vector that are to be summed to create the
new vectors? ?tapply might then be relevant here, but that's just a
Genentech Nonclinical Biostatistics
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
On Fri, Jan 23, 2015 at 12:45 AM, Kathryn Lord
<kathryn.lord2000 at gmail.com> wrote:
> 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.
> Kathryn Lord
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help