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

From: Rob Tirrell <rpt_at_stanford.edu>
Date: Wed, 09 Mar 2011 14:04:56 -0800

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 | rpt_at_stanford.edu | (607) 437-6532
Program in Biomedical Informatics | Butte Lab | Stanford University



> sqldf("select sum(return(var1)) as XSUM,
> Y as Y
> from testdf
> group by Y")
>
>
>
> --
> Michael Schumacher
> mike.schumacher_at_gmail.com
> Manager Data & Analytics, ValueClick
> 818-851-8638
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]] ______________________________________________ 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.
Received on Wed 09 Mar 2011 - 22:09:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Mar 2011 - 22:10:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive