Hi, How do I do something like this without using sqldf? a <- sqldf("SELECT COUNT(*) FROM b WHERE c = 'd'") or e <- sqldf("SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f") greetings, el
Hi, With the new package "dplyr" you can create equivalent SQL sintaxt queries like the one you need. You can find examples of how to apply it here: http://martinsbioblogg.wordpress.com/2014/03/26/using-r-quickly-calculating-summary-statistics-with-dplyr/ http://martinsbioblogg.wordpress.com/2014/03/27/more-fun-with-and/ Regards, Carlos. 2014-05-02 23:23 GMT+02:00 Dr Eberhard Lisse <nospam@lisse.na>:> Hi, > > How do I do something like this without using sqldf? > > a <- sqldf("SELECT COUNT(*) FROM b WHERE c = 'd'") > > or > > e <- sqldf("SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f") > > greetings, el > > ______________________________________________ > 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. >-- Saludos, Carlos Ortega www.qualityexcellence.es [[alternative HTML version deleted]]
By making the effort to learn R? See e.g. the "Introduction to R" tutorial that ships with R. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." H. Gilbert Welch On Fri, May 2, 2014 at 2:23 PM, Dr Eberhard Lisse <nospam at lisse.na> wrote:> Hi, > > How do I do something like this without using sqldf? > > a <- sqldf("SELECT COUNT(*) FROM b WHERE c = 'd'") > > or > > e <- sqldf("SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f") > > greetings, el > > ______________________________________________ > R-help at 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.
?table ?aggregate Also, packages plyr, data.table, and dplyr. You might consider reading [1], but if your interests are really as simple as your examples then the table function should be sufficient. That function is discussed in the Introduction to R document that you really should have read before posting here. [1] http://www.jstatsoft.org/v40/i01/ --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On May 2, 2014 2:23:13 PM PDT, Dr Eberhard Lisse <nospam at lisse.NA> wrote:>Hi, > >How do I do something like this without using sqldf? > >a <- sqldf("SELECT COUNT(*) FROM b WHERE c = 'd'") > >or > >e <- sqldf("SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f") > >greetings, el > >______________________________________________ >R-help at 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.
On Fri, May 2, 2014 at 5:23 PM, Dr Eberhard Lisse <nospam at lisse.na> wrote:> Hi, > > How do I do something like this without using sqldf? > > a <- sqldf("SELECT COUNT(*) FROM b WHERE c = 'd'") > > or > > e <- sqldf("SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f") >In the examples section at the bottom of ?sqldf are a number of SQL statements and the corresponding R statements. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com