In addition to Michael's answers, there are packages that allow you to use SQL syntax on R data objects, so you could probably just use what you are familiar with.
On Sat, Mar 24, 2012 at 9:32 AM, reeyarn <reey...@gmail.com> wrote: > Hi, I want to run something like > SELECT firm_id, count(*), mean(value), sd(value) > FROM table > GROUP BY firm_id; > > But I have to write a for loop like > for ( id in unique(table$firm_id ) { > print(paste( id, mean(table[firm_id == id, "value"]) )) > } > > Is there any way to do it easier? Thanks :) > > > Best, > Reeyarn Lee > > [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com ______________________________________________ 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.