Hello, I'm accessing a MySQL database from inside R and had a problem with a function. In the database, there is data from years 1985 to 2007 that I would like to retrieve. I can easily get the data from one year by the following: info1985=dbGetQuery(con, statement='the SQL query') Inside the statement, I have a column that is set to the desired year (e.g. table.column=1985) through a WHERE clause, but when I write a function like the following: getinfo=function(t){dbGetQuery(con,statement='the SQL query')} and instead of using a specific year, I substitute in t (e.g. table.column=t) in a WHERE clause When I go to do allinfo=sapply(c(1985:2007),getinfo) I get the following error message: RS-DBI driver: (could not run statement: Unknown column 't' in 'where clause') Is there anyway around this error? Or is not possible to substitute in years with a function and sapply through SQL? Thanks so much.
[[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.