Hi guys,

I want to create variable on the fly: for example

for (i in 1:10) {
    cat(paste("VAR",i,sep=""))
}
Will print VAR1, VAR2 etc up to VAR10. However I want to make these into
variables, and then give them a value, for example:

vect = c(10:20)

for (i in 1:10) {
    cat(paste("VAR",i,sep="")) = vect[i]
}

THis doesnt work but I hope it demonstrates what I'm trying to do: I'm
trying to produce 10 variables, from VAR1 to VAR10, which have the numbers
11...20 respectively, so I would end up with 

VAR1 = 11
VAR2 = 12
...
VAR10 = 20

Hope this makes sense!! Does anyone have any ideas?
-- 
View this message in context: 
http://www.nabble.com/produce-variable-on-the-fly-tp18943749p18943749.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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