[R] How do I generate multiple (similar) objects within R?

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Nov 18 19:01:57 CET 2008


An, again FAQ "How can I turn a string into a variable?" ....

Uwe Ligges



Nicklas Pettersson wrote:
> Hi,
> 
> I wonder if anyone knows how to generate a list of objects, e.g. ten 
> vectors with names: vect1, vect2, ... , vect10.
> My own idea was to use something like:
> 
>    for (i in 1:10)
>    print(paste("vect", i,"<-NULL",sep=""))
> 
> but the result is:
> 
> "vect1<-NULL"
> ...
> "vect10<-NULL"
> 
> and not
> 
> vect1<-NULL
> ...
> vect10<-NULL
> 
> as I would like. Does anyone know?
> 
> ______________________________________________
> 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.



More information about the R-help mailing list