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

From: jim holtman <jholtman_at_gmail.com>
Date: Tue, 18 Nov 2008 13:03:13 -0500

'assign'

for (i in 1:10) assign(paste('vect', i, sep=''), NULL)

or use a 'list'

On Tue, Nov 18, 2008 at 12:58 PM, Nicklas Pettersson <Nicklas.Pettersson_at_stat.su.se> 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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

______________________________________________
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.
Received on Tue 18 Nov 2008 - 18:09:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Nov 2008 - 18:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive