[R] Problem to male an Index in looping
jim holtman
jholtman at gmail.com
Sun Sep 28 00:40:47 CEST 2008
I think you want 'assign':
for (i in 1:3){
assign(qrnox[i], rq(nox~factor(year)+factor(state)+pcinc+I(pcinc^2)+I(pcinc^3),
tau=quant[i], data=exmp))
}
better yet, use a list:
result <- list()
for (i in 1:3){
result[[1]] <- rq(....)
}
result[[1]]
On Sat, Sep 27, 2008 at 4:24 PM, dimitrisk <gamitor at gmail.com> wrote:
>
> Hi,
>
> I am trying to use (i) as an index but R considers it as a function and not
> as text. To be more specific I would like for example to estimate some
> regressions named qrnox1, qrnox2, qrnox3,..... and so on. But when I am
> using qrnox(i) ot qrnox[i] it tries to find the ith element of vector qrnox.
> The thing is that I want to estimate the qrnoxi regression and not the
> qrnox(i) function or whatever. Even if I create a vector text as elements
> like qrnox<-c("qrnox1", "qrnox2", "qrnox3", .....). It doesn't work either.
> Is there any way to do it ? I have post the part of the code
>
> Thanks
>
> Dimitris
>
> #######################################################
> quant<-c(0.25, 0.5, 0.75)
> qrnox<-c("qrnox1", "qrnox2", "qrnox3")
>
> for (i in 1:3){
> qrnox[i]<-rq(nox~factor(year)+factor(state)+pcinc+I(pcinc^2)+I(pcinc^3),
> tau=quant[i], data=exmp)
> }
>
> summary(qrnox1)
> --
> View this message in context: http://www.nabble.com/Problem-to-male-an-Index-in-looping-tp19706138p19706138.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list