Re: [R] Adding same items together in data.frame

2011-05-16 Thread wong, honkit (Stephen)
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

Re: [R] Adding same items together in data.frame

2011-05-14 Thread John Kane
And another approach: = library(reshape2) mydata <- data.frame(aa = sample(Cs(a,b,c,d,e),10,replace=TRUE), bb = sample(1:10, 10, replace=TRUE)) (m1 <- melt(mydata)) =

Re: [R] Adding same items together in data.frame

2011-05-13 Thread Steve Lianoglou
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

Re: [R] Adding same items together in data.frame

2011-05-13 Thread Dennis Murphy
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