Re: [R] Sum over indexed value

2009-11-16 Thread cls59
Gunadi wrote: > > I am sure this is easy but I am not finding a function to do this. > > I have two columns in a matrix. The first column contains multiple entries > of numbers from 1 to 100 (i.e. 10 ones, 8 twos etc.). The second column > contains unique numbers. I want to sum the numbers in

Re: [R] Sum over indexed value

2009-11-16 Thread Henrique Dallazuanna
Try this: with(DF, rowsum(Col2, Col1)) On Mon, Nov 16, 2009 at 3:49 PM, Gunadi wrote: > > I am sure this is easy but I am not finding a function to do this. > > I have two columns in a matrix. The first column contains multiple entries > of numbers from 1 to 100 (i.e. 10 ones, 8 twos etc.). The

Re: [R] Sum over indexed value

2009-11-16 Thread smu
P=data.frame(x=c(1,1,2,3,2,1),y=rnorm(6)) tapply(P$y,P$x,sum) regards, stefan On Mon, Nov 16, 2009 at 09:49:17AM -0800, Gunadi wrote: > > I am sure this is easy but I am not finding a function to do this. > > I have two columns in a matrix. The first column contains multiple entries > of n

[R] Sum over indexed value

2009-11-16 Thread Gunadi
I am sure this is easy but I am not finding a function to do this. I have two columns in a matrix. The first column contains multiple entries of numbers from 1 to 100 (i.e. 10 ones, 8 twos etc.). The second column contains unique numbers. I want to sum the numbers in column two based on the inde