Re: [R] summing up colum values for unique IDs when multiple ID's exist in data frame

2007-05-29 Thread jim holtman
try this: > x <- " IDval + 1 A 0.100 + 2 B 0.001 + 3 C -0.100 + 4 A 0.200 + " > x <- read.table(textConnection(x), header=TRUE) > (z <- tapply(x$val, x$ID, sum)) A B C 0.300 0.001 -0.100 > data.frame(ID=names(z), val=z) IDval A A 0.300 B B 0.001 C C -0.100 >

Re: [R] summing up colum values for unique IDs when multiple ID's exist in data frame

2007-05-29 Thread Thomas Lumley
On Tue, 29 May 2007, Seth Falcon wrote: > "Young Cho" <[EMAIL PROTECTED]> writes: > >> I have data.frame's with IDs and multiple columns. B/c some of IDs >> showed up more than once, I need sum up colum values to creat a new >> dataframe with unique ids. >> >> I hope there are some cheaper ways of

Re: [R] summing up colum values for unique IDs when multiple ID's exist in data frame

2007-05-29 Thread Seth Falcon
"Young Cho" <[EMAIL PROTECTED]> writes: > I have data.frame's with IDs and multiple columns. B/c some of IDs > showed up more than once, I need sum up colum values to creat a new > dataframe with unique ids. > > I hope there are some cheaper ways of doing it... Because the > dataframe is huge, it

[R] summing up colum values for unique IDs when multiple ID's exist in data frame

2007-05-29 Thread Young Cho
I have data.frame's with IDs and multiple columns. B/c some of IDs showed up more than once, I need sum up colum values to creat a new dataframe with unique ids. I hope there are some cheaper ways of doing it... Because the dataframe is huge, it takes almost an hour to do the task. Thanks so muc