I am trying to create a set of vectors which have similar names. They have a common part and an extra unique part. I am sure I have seen questions on this before but I have been unable to find it in the archive. There are examples of sets of names for columns of a data frame, but not for individual vectors. Suppose I want vectors named myvar.1 myvar.2 etc. I tried:> as.name(paste("myvar","1",sep="."))<-1:10Error: Target of assignment expands to non-language object But:> is.language(as.name(paste("myvar","1",sep=".")))[1] TRUE Any suggestions as to how to do this? David Scott _________________________________________________________________ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland NEW ZEALAND Phone: +64 9 373 7599 ext 6830 Fax: +64 9 373 7018 Email: d.scott at Auckland.ac.nz President, New Zealand Statistical Association Head, Department of Statistics, University of Auckland -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 20 Dec 2000, David Scott wrote:> > I am trying to create a set of vectors which have similar names. They have > a common part and an extra unique part. I am sure I have seen questions on > this before but I have been unable to find it in the archive. There are > examples of sets of names for columns of a data frame, but not for > individual vectors. > > Suppose I want vectors named myvar.1 myvar.2 etc. > > I tried: > > as.name(paste("myvar","1",sep="."))<-1:10 > Error: Target of assignment expands to non-language objectThe problem is that there isn't an "as.name<-" function so you can't use as.name on the left-hand side of an assignment. You probably mean assign(paste("myvar","1",sep="."),1:10) but your life might well be easier if you just had a list called myvar and had vectors myvar[[1]], myvar[[2]], and so on. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello David, maybe this helps you:> assign(paste("myvar","1",sep="."),1:10) > ls()[1] "myvar.1"> myvar.1[1] 1 2 3 4 5 6 7 8 9 10 Greetings jan On Wed, 20 Dec 2000, David Scott wrote:> > I am trying to create a set of vectors which have similar names. They have > a common part and an extra unique part. I am sure I have seen questions on > this before but I have been unable to find it in the archive. There are > examples of sets of names for columns of a data frame, but not for > individual vectors. > > Suppose I want vectors named myvar.1 myvar.2 etc. > > I tried: > > as.name(paste("myvar","1",sep="."))<-1:10 > Error: Target of assignment expands to non-language object > > But: > > is.language(as.name(paste("myvar","1",sep="."))) > [1] TRUE > > Any suggestions as to how to do this? > > David Scott > > _________________________________________________________________ > David Scott Department of Statistics > The University of Auckland, PB 92019 > Auckland NEW ZEALAND > Phone: +64 9 373 7599 ext 6830 Fax: +64 9 373 7018 > Email: d.scott at Auckland.ac.nz > > President, New Zealand Statistical Association > Head, Department of Statistics, University of Auckland > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- +----------------------------------- Jan Goebel (mailto:jgoebel at diw.de) DIW Berlin Longitudinal Data and Microanalysis K?nigin-Luise-Str. 5 D-14195 Berlin -- Germany -- phone: 49 30 89789-377 +----------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._