Thanks Gabor!
This is exactly what I was searching for! --- And it works like a charm.
On Fri, Aug 17, 2012 at 1:03 PM, Gabor Grothendieck
wrote:
> On Thu, Aug 16, 2012 at 3:30 PM, Kenneth Rose wrote:
>> Hi R community
>>
>> I copied a bit of my R code that gets some data from a database. You
I tried these two and testquery2 now does the job :) Somehow the str_c
function from the stringr package doesn't work when I run the sqlQuery
function even though the testquery string is the same as testquery2
string. Thanks for the pointers!
fromdate <- c("'2005-01-01 00:00:00'")
testquery <- st
On Thu, Aug 16, 2012 at 3:30 PM, Kenneth Rose wrote:
> Hi R community
>
> I copied a bit of my R code that gets some data from a database. You
> won't be able to run the code, but I am a beginner so you will
> probably understand what going on.
>
> I would like to make a variable I can refer to in
I sometimes do this sort of thing with "tricks" like this:
sql <- "select * from mytable where dt >= 'ADATE'"
dbGetQuery( con, gsub('ADATE', '2012-06-12 23:14', sql) )
Or if mydates is a vector of dates stored as a POSIXt object:
for (id in mydates) {
dbGetQuery( con, gsub('ADATE', form
Perhaps the sprintf function is what you are looking for. It is one
way to insert information from a variable into a string. A couple of
other options are paste, paste0, and the gsubfn package, but I think
sprintf will be simplest for what you are asking.
On Thu, Aug 16, 2012 at 1:30 PM, Kenneth
Hi R community
I copied a bit of my R code that gets some data from a database. You
won't be able to run the code, but I am a beginner so you will
probably understand what going on.
I would like to make a variable I can refer to inside the sqlQuery.
Instead of writing the start date and time (ex
6 matches
Mail list logo