try this:

x <- lapply(v.fundno, function(.fund){
    sqlQuery(channel, paste("select mret from monthly_return where
crsp_fundno =",
        .fund, 'and caldt > 19700630 order by caldt')
})
result <- do.call(rbind, x)

On Fri, Mar 26, 2010 at 2:07 PM, muting <mt208...@dal.ca> wrote:

>
> Hi Charlie
>
> Thank you for your advice, but it makes my R dead...
>
> My head(v.fundno) is
> > head(v.fundno)
> [1] "2899" "2903" "2960" "3094" "3095" "3211"
>
> I tried to plug in the specific value like 2890 and 2960 :
> gmret.2899<-sqlQuery(channel,"select caldt, mret from Monthly_returns where
> crsp_fundno = 2899 and caldt > 19700630 order by caldt")
> gmret.2899
> gmret.2903<-sqlQuery(channel,"select mret from Monthly_returns where
> crsp_fundno = 2903 and caldt > 19700630 order by caldt")
> gmret.2903
> test<-cbind(gmret.2899,gmret.2903)
> test
> I got what I need:
> > head(test)
>     caldt        mret       mret.1
> 1 19700731  0.07165605  0.015037594
> 2 19700831  0.02971768 -0.048148148
> 3 19700930  0.06060606  0.221789883
> 4 19701030 -0.02993197 -0.103503185
> 5 19701130  0.01317504  0.008880995
> 6 19701231  0.06285714  0.045774648
>
> but there's 310 data set I need, I cant do them by hand like this, I need
> the loop. could u please help me out?
>
> Thank you very much
>
> Muting
> --
> View this message in context:
> http://n4.nabble.com/string-problems-in-R-tp1685419p1692612.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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

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

Reply via email to