On Tue, 12 Aug 2008, Ben Bolker wrote:

jimineep <jamesrperkins <at> hotmail.com> writes:



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 is almost a candidate for a FAQ: see


It *is*  FAQ 7.21.

     -thomas


Thomas Lumley                   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]       University of Washington, Seattle

______________________________________________
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