I m relatively new to R. I m using the RMySQL Library to get some data and then process it in R. My code looks something like this.
arg<-commandArgs(TRUE)
rs<-dbSendQuery(con, "select owner_name, domain, count(*) as freq from playlist
where DATE(time_last_update) between arg[1] AND arg[2] group by owner_name;")
d<-fetch(rs, n=0)
d$test<-apply(d,1,function(row) 1)
dp<-ddply(d, .(test), transform, percentile=ecdf(freq)(freq))
write.csv(dp, file="/usr/monthly_analytics/viewer_data/playlist.csv")
I m pretty much sure this is incorrect. I m calling R with the following parameters.
Rscript test.R 2013-06-25 2012-12-25
As expected the MySQL server is returning error with query. What is the correct way to pass an argument inside the SQL statement from R?
Thank you in advance.