On 04-12-2012, at 08:59, T Bal wrote: > Hi, > I have the following data: > > 0 12 > 1 10 > 1 4 > 1 6 > 1 7 > 1 13 > 2 21 > 2 23 > 2 20 > 3 18 > 3 17 > 3 16 > 3 27 > 3 33 > 4 11 > 4 8 > 4 19 > 4 16 > 4 9 > > > In this data file I would like to sum the numbers of second column which > belong to the same number in the first column. > So the output would be: > > 0 12 > 1 40 > 2 64 > 3 111 > etc.
Using Pascal's test object you can also use aggregate aggregate(test$V2,by=list(test$V1),FUN=sum) Berend ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.