Re: [R] SQLDF - Submitting Queries with R Objects as Columns

2011-03-09 Thread Rob Tirrell
You're submitting queries for SQLDF to execute as strings. So, if you want to use a variable column name, sprintf() or paste() your statement together, like: sqldf(sprintf('select sum(%s) as XSUM, Y as Y from testdf group by Y', var1)) -- Robert Tirrell | r...@stanford.edu | (607) 437-6532 Progra

Re: [R] SQLDF - Submitting Queries with R Objects as Columns

2011-03-09 Thread Gabor Grothendieck
On Wed, Mar 9, 2011 at 11:41 AM, Mike Schumacher wrote: > Fellow R programmers, > > I'd like to submit SQLDF statements with R objects as column names. > > For example, I want to assign "X" to "var1"  (var1<-"X") and then refer to > "var1" in the SQLDF statement.  SQLDF needs to understand that wh

[R] SQLDF - Submitting Queries with R Objects as Columns

2011-03-09 Thread Mike Schumacher
Fellow R programmers, I'd like to submit SQLDF statements with R objects as column names. For example, I want to assign "X" to "var1" (var1<-"X") and then refer to "var1" in the SQLDF statement. SQLDF needs to understand that when I reference "var1", it should look for "X" in the dataframe. Th