Stem Cell Research Building, Room G2035
259 Campus Drive
Stanford, CA 94305
-Original Message-
From: Dennis Murphy [mailto:djmu...@gmail.com]
Sent: Friday, May 13, 2011 8:05 PM
To: wong, honkit (Stephen)
Cc: r-help@r-project.org
Subject: Re: [R] Adding same items together in data.frame
mydata))
=
--- On Fri, 5/13/11, wong, honkit (Stephen) wrote:
> From: wong, honkit (Stephen)
> Subject: [R] Adding same items together in data.frame
> To: r-help@r-project.org
> Received: Friday, May 13, 2011, 7:06 PM
> Dear All,
> I am new to R. I have a 2 col
Hi,
On Fri, May 13, 2011 at 7:06 PM, wong, honkit (Stephen)
wrote:
> Dear All,
> I am new to R. I have a 2 column data frame with more than ten thousand
> rows. Something like below. I want to add up all duplicated items, e.g. the
> three "aa" add up together to get a single value gene=a, value=7
Hi:
There are many ways to do this sort of thing in R; one way is (naming
your example data frame d)
aggregate(value ~ gene, data = d, FUN = sum)
gene value
1 aa74
2 bb10
3 cc 9
4 dd 100
5 ee55
This code line works for R-2.11.0 and later.
HTH,
Dennis
On Fri, May 1
Dear All,
I am new to R. I have a 2 column data frame with more than ten thousand
rows. Something like below. I want to add up all duplicated items, e.g. the
three "aa" add up together to get a single value gene=a, value=74. How can I
do that?? Thanks for help !
gene value
aa 20
bb 10
cc
5 matches
Mail list logo