Hello All,
I've created a function as follows so as to use it in a loop.

freq<-function(i)
{
library(RODBC)
paste(i,"<-sqlQuery(conn,","'","select   click_flg, open_flg,", i ," from
modeling_5')",sep="")
}

freq(i="AQI")
[1] "AQI<-sqlQuery(conn,'select   click_flg, open_flg,AQI from modeling_5')"

What I was expecting was the result of the sql query "select   click_flg,
open_flg,AQI from modeling_5" be put into the object "AQI". However it just
resolves to a string.

Note: the query - AQI<-sqlQuery(conn,'select   click_flg, open_flg,AQI from
modeling_5')
works fine on its own.

How can make the function execute the resolved expression rather than just
return the string result of the resolution.

Many thanks.

PS: I did search on the internet including this site but could not find a
suitale solution.


--
View this message in context: 
http://r.789695.n4.nabble.com/Executing-a-function-correctly-tp3665765p3665765.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to