[R] Executing a function correctly

saskay sashi1985 at gmail.com
Wed Jul 13 20:38:11 CEST 2011


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.



More information about the R-help mailing list