see also tapply()

e.g.

a<-c(1,1,1,2,2,2,3,3,3)
b<-c(10,10,10,15,15,15,20,20,20)
c.dat<-data.frame(a,b)

tapply(c.dat[,2],c.dat[,1],sum)

Mike

On Thu, Dec 2, 2010 at 10:33 AM, Ivan Calandra <ivan.calandra@uni-hamburg.de
> wrote:

> see ?aggregate, and ?summaryBy (in package doBy)
> I think ddply (in package plyr) could also do the job
>
> Ivan
>
> Le 12/2/2010 17:24, chris99 a écrit :
>
>> I am trying to aggregate data in column 2 to identifiers in col 1
>>
>> eg..
>>
>> take this>
>>
>> identifier       quantity
>> 1                     10
>> 1                     20
>> 2                     30
>> 1                     15
>> 2                     10
>> 3                     20
>>
>> and make this>
>>
>> identifier         quantity
>> 1                    45
>> 2                    40
>> 3                    20
>>
>>
>> Thanks in advance for your help!
>>
>
> --
> Ivan CALANDRA
> PhD Student
> University of Hamburg
> Biozentrum Grindel und Zoologisches Museum
> Abt. Säugetiere
> Martin-Luther-King-Platz 3
> D-20146 Hamburg, GERMANY
> +49(0)40 42838 6231
> ivan.calandra@uni-hamburg.de
>
> **********
> http://www.for771.uni-bonn.de
> http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Michael Rennie, Research Scientist
Fisheries and Oceans Canada, Freshwater Institute
Winnipeg, Manitoba, CANADA

	[[alternative HTML version deleted]]

