I am trying with the below code but getting the error:
I tried with both "sprintf", "fn$sqldf" to select the output.
my function will run two times one with the column "a" and another with column "e".
Please suggest. I got this suggestion from some member and edit the code.enter code here
db2 = data.frame(a = c(1,2,3),
b = c("b","a","c"),
e= c(4,6,3))
library(sqldf)
extrct = function(id)
{
filedata1 <- sprintf("select max(%s) as maxid from db2",id)
filedata3 <- fn$sqldf("select max(id) as maxid from db2")
}
extrct(a)
extrct(e)
ERROR:
Error in sprintf("select max(%s) as maxid from db2", id) :
object 'a' not found
Error in sprintf("select max(%s) as maxid from db2", id) :
object 'e' not found