1

Tried to search for an answer using "SQLDF append in code", but I couldnt find any answer.

Basically, I'd like to be able to write something like that :

divisor<-4
result<-sqldf("SELECT id, some_number/ " . divisor . " FROM my_table")

but I can't find a way to have divisor included in the SQL statement : Error: unexpected symbol in "result<-sqldf("SELECT id, some_number/ " ."

I tried having &, + and nothing instead of the dots ., but I can't find anything that works.

I also tried "SELECT id, some_number/divisor FROM my_table", without any " " around divisor, but I get error in statement: no such column: divisor

Thanks.

1

1 Answer 1

1

You can use

result<-sqldf(sprintf("SELECT id, some_number/%d FROM my_table", divisor))

Hope this helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.