This is actually FAQ 7.21 (though the FAQ does not specify how to create the 
name in a loop).  As others have mentioned, the most important part of the 
Answer is that it is better to use a list instead.

What searching did you do before posting?  Is there some way that the FAQ could 
be changed that would have made your searching turn up the FAQ answer?

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of maciek kryza
> Sent: Monday, June 13, 2011 8:14 AM
> To: r-help@r-project.org
> Subject: [R] use variable value to create new variable name
> 
> Hi,
> Is it possible (and how) to use a variable value to create a name of a
> new R
> variable? I want to do something like this:
> 
> for (i in 1:3) {
> newvarialbe_#i# = somedata
> }
> 
> where #i# is a value stored by i. In the first loop, there will be
> newvariable_1, in second newvariable_2 and so on.
> Thanks in advance,
> Maciek
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@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.

______________________________________________
R-help@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.

Reply via email to