Using the built in data.frame iris sum each of the first 4 columns for each value of the 5th column.
rowsum(iris[,-5], iris[,5]) On 4/20/06, Sachin J <[EMAIL PROTECTED]> wrote: > Hi, > > How can I accomplish this in R. Example: > > R1 R2 > 3 101 > 4 102 > 3 102 > 18 102 > 11 101 > > I want to find Sum(101) = 14 - i.e SUM(R1) where R2 = 101 > Sum(102) = 25 - SUM(R2) where R2 = 102 > > TIA > Sachin > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
