tags:

views:

60

answers:

1

Simple question, but cannot find the answer.

Instead of:

Df<-sqlQuery(ch,"SELECT * FROM tblTest WHERE Id=25")

I want a more dynamic piece of code. Something like:

Id<-25
Df<-sqlQuery(ch,c("SELECT * FROM tblTest WHERE Id=",Id))

But this is not correct. I'm still struggling with R...

+3  A: 

You want:

Df<-sqlQuery(ch,paste("SELECT * FROM tblTest WHERE Id=",Id))

c concatenates into a vector, paste is for string concatenation.

Joshua Ulrich
As I said, a simple question ;-) Thanks!
waanders
For C lovers there is `sprintf` which works like in C.
mbq