Try this: aggregate(x["VALUE"], list(substr(x[,"ID"], 1, 1)), sum)
On Thu, Jul 9, 2009 at 7:27 PM, Mark Na <mtb...@gmail.com> wrote: > Dear R-helpers, > > I have two rows in my dataframe: > > ID VALUE > 1A 10 > 1B 15 > > and I would like to combine these two rows into a single (new) row in my > dataframe: > > ID VALUE > 1 25 > > ...simply by specifying a new value for ID and summing the two VALUES. > > I have been trying to do this with with rbind, but it's not working. > > I'd appreciate any pointers. > > Thanks, Mark Na > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ 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.