[R] dbSendQuery with R variables

Seth Falcon seth at userprimary.net
Tue May 11 22:15:44 CEST 2010


On 5/11/10 5:01 AM, jim holtman wrote:
> ?paste
>
> On Mon, May 10, 2010 at 6:21 PM, Jonathan Greenberg
> <greenberg at ucdavis.edu>wrote:
>
>> Rhelpers:
>>
>> I'd like to modify this RSQLite statement:
>>
>> rs_stations<-dbSendQuery(con_stations, "select * from stations")
>>
>> so that stations is actually an R variable, e.g.:
>>
>> stations=c("stationA","stationB")
>>
>> How would I modify the above statement to query from stations[[1]]
>> (aka "stationA")?

In the end, I think paste is your only option.  The latest version of 
RSQLite does support parameterized SELECT queries, but you cannot use 
the parameters to specify table names, only values.

For details of what is supported, try reading through the examples in 
help("dbSendPreparedQuery")


+ seth

-- 
Seth Falcon | @sfalcon | http://userprimary.net/



More information about the R-help mailing list