Skip to content
Prev 253052 / 398500 Next

SQLDF - Submitting Queries with R Objects as Columns

On Wed, Mar 9, 2011 at 11:41 AM, Mike Schumacher
<mike.schumacher at gmail.com> wrote:
Here are two ways:

sqldf(sprintf("select sum(%s) XSUM, Y from testdf group by Y", var1))

fn$sqldf("select sum($var1) XSUM, Y from testdf group by Y")

See ?sprintf

fn comes from the gsubfn package (which is automatically pulled in by
sqldf) and adds quasi perl style string interpolation to the arguments
passed to the function call it prefaces.  See
http://gsubfn.googlecode.com and ?fn