Hello all I have been working on my thesis using R. I am a newbie to R and met a problem that bothered me for a while due to my lack of acquaintance of R.
I am using R to query from SQL. I got a list of crsp_fundno of G-style mutual funds which is still alive. I use the following codes and got what I want: library(RODBC) channel<-odbcConnect("CRSPFUND") g.crspfundno<-sqlQuery(channel,"select crsp_fundno from Fund_style where wbrger_obj_cd = 'G'order by crsp_fundno") g.crspfundno (got crsp_fundno of G-style fund from Fund_style table) y.crspfundno<-sqlQuery(channel,"select crsp_fundno from Fund_hdr where dead_flag = 'N'and end_dt=20091231 order by crsp_fundno") y.crspfundno (got crsp_fundno of still alive fund from Fund_hdr table) g$key<-paste(g.crspfundno$crsp_fundno) y$key<-paste(y.crspfundno$crsp_fundno) v.fundno<-intersect(g$key,y$key) (using intersect to get crsp_fundno of G-style mutual funds which is still alive.) v.fundno What i need to do next is using the v.fundno I got to query from another table "Monthly_return" to get the mret coresponding to every v.fundno. I have only a basic idea of the code: for (i in 1:length(v.fundno)){ gmret<-sqlQuery(channel,"select mret from Monthly_returns where crsp_fundno = toString(v.fundno[i])") } gmret R gave me an error with undefined function "toString" I know there should be some details added in to get it right,like define an object or how to convert number to string.. I would be appreciated if anyone gives me any clue about it. Muting ______________________________________________ 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.