Hi there In the course of my diploma thesis in climatology I have encountered a difficult R-Problem that I cannot solve. I want to fill R-Objects (whose names should depend on j) with numbers at the i-th position. The resulting Objects should be something like: RQuadratStep1, RQuadratStep2, RQuadratStep3 ... filled with Elements like c(0.324, 0.456, 0.657 ...) Below is a short version of how I have tried to solve it but I don't know how to insert numbers at the i-th place. The problem seems to be the "assign" line. Thanks a lot for all hints. for(j in 1:10) { for(i in 1:30) { fit<-lm(annJMSLTv.box~.,data=data.frame(annJMSLTv.box=annJMSLTv.box[,i],allTreerings[,1:15]) backfit<-step(fit,trace=F,steps=1) assign(eval(parse(text=paste("RQuadratStep",j,sep=""))),round(summary(fit)$r.squared, dig=3)) } } -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Hi there > > In the course of my diploma thesis in climatology I have encountered > > a difficult R-Problem that I cannot solve. I want to fill R-Objects > > (whose names should depend on j) with numbers at the i-th position. > > The resulting Objects should be something like: > > RQuadratStep1, RQuadratStep2, RQuadratStep3 ... filled with Elements likeyou may want to use lists: mylist <- list() for (j in 1:10) mylist <- c(mylist, list(rnorm(10))) and> mylist[[5]][1] 1.0530570 0.4205237 -0.7135633 -0.1252135 -0.2001246 2.1129394 [7] -1.8155177 1.2549754 -1.1938755 0.3253695 is an ordinary vector> mylist[[5]][1][1] 1.053057 Torsten> > c(0.324, 0.456, 0.657 ...) > > Below is a short version of how I have tried to solve it but I don't > > know how to insert numbers at the i-th place. The problem seems to be > > the "assign" line. Thanks a lot for all hints. > > for(j in 1:10) { > > for(i in 1:30) { > > fit<-lm(annJMSLTv.box~.,data=data.frame(annJMSLTv.box=annJMSLTv.box[,i],allTreerings[,1:15]) > > backfit<-step(fit,trace=F,steps=1) > > assign(eval(parse(text=paste("RQuadratStep",j,sep=""))),round(summary(fit)$r.squared, dig=3)) > > } > > } > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Why don't you want to have RQuadratStep as an array or a list? The problem would vanish then, wouldn't it? On Fri, 15 Feb 2002, Andreas Pauling wrote:> Hi there > > In the course of my diploma thesis in climatology I have encountered > > a difficult R-Problem that I cannot solve. I want to fill R-Objects > > (whose names should depend on j) with numbers at the i-th position. > > The resulting Objects should be something like: > > RQuadratStep1, RQuadratStep2, RQuadratStep3 ... filled with Elements like > > c(0.324, 0.456, 0.657 ...) > > Below is a short version of how I have tried to solve it but I don't > > know how to insert numbers at the i-th place. The problem seems to be > > the "assign" line. Thanks a lot for all hints. > > for(j in 1:10) { > > for(i in 1:30) { > > fit<-lm(annJMSLTv.box~.,data=data.frame(annJMSLTv.box=annJMSLTv.box[,i],allTreerings[,1:15]) > > backfit<-step(fit,trace=F,steps=1) > > assign(eval(parse(text=paste("RQuadratStep",j,sep=""))),round(summary(fit)$r.squared, dig=3)) > > } > > } > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- *********************************************************************** Christian Hennig Seminar fuer Statistik, ETH-Zentrum (LEO), CH-8092 Zuerich (current) and Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg hennig at stat.math.ethz.ch, http://stat.ethz.ch/~hennig/ hennig at math.uni-hamburg.de, http://www.math.uni-hamburg.de/home/hennig/ ####################################################################### ich empfehle www.boag.de -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._