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

Ben Bolker bolker at ufl.edu
Tue Nov 18 23:01:49 CET 2008


Nicklas Pettersson <Nicklas.Pettersson <at> stat.su.se> writes:

> 
> 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=""))
> 

  I think this is FAQ 7.21, "how can I turn a string into
a variable":

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f

  cheers
    Ben Bolker



More information about the R-help mailing list