[R] Question regarding sqldf

Rizzo.Michael at epamail.epa.gov Rizzo.Michael at epamail.epa.gov
Thu Jul 30 19:46:29 CEST 2009


Hello,

I am having a problem using sqldf.  I'm trying to choose a subset of
observations from a data set based on the date and maximum value of a
variable by date.

Here is the code I am using:

test<-sqldf("select distinct * from bextuse group by sdate having
bext=max(bext)",method="raw");

The result I get back is a data frame with 0 rows and 0 columns.  I have
tried the code in another program that utilizes SQL, and I retrieve the
14 rows I was expecting to get.
I looked at the SQLite information on the web, and it mentions that the
"having" clause can be used to select observations from grouped data
using aggregating functions.

Any help or advice is greatly appreciated.




More information about the R-help mailing list