As Greg wrote, a list is in most circumstances a better way to store
many objects.
But you can use 'assign' and 'get' to create and access (global) variables

#creation
for (i in 1:100) assign(paste("var",i,sep=""),rnorm(5))

#access i-th variable
i<-15
get(paste("var",i,sep=""))

hth.

Am 02.02.2011 21:36, schrieb hypermonkey22:
> 
> Hi all,
> 
> I've been looking for a simple answer to the following problem.
> 
> Let's say that I can loop through, say, 100 values that need to be assigned
> to, say, the variables var1:var100.
> 
> Is there an elegant way to do this?
> 
> I have seen one or two similar questions...but they tend to be in more
> complicated contexts.
> Simple question, hopefully with a simple answer.
> 
> Thanks very much!


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

______________________________________________
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