Re: [R] produce variable on the fly

2008-08-12 Thread Thomas Lumley
On Tue, 12 Aug 2008, Ben Bolker wrote: jimineep 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

Re: [R] produce variable on the fly

2008-08-12 Thread Ben Bolker
jimineep 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: > > v

Re: [R] produce variable on the fly

2008-08-12 Thread Charles C. Berry
On Tue, 12 Aug 2008, jimineep wrote: Hi guys, I want to create variable on the fly: for example See ?assign HTH, Chuck 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 val

Re: [R] produce variable on the fly

2008-08-12 Thread David Hajage
> vect = c(10:20) > for (i in 1:10) { + assign(paste("VAR",i,sep=""), vect[i]) + } > VAR1 [1] 10 > VAR2 [1] 11 2008/8/12 jimineep <[EMAIL PROTECTED]> > > 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,

Re: [R] produce variable on the fly

2008-08-12 Thread Erik Iverson
?assign , or consider a named vector/list. jimineep wrote: 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:

[R] produce variable on the fly

2008-08-12 Thread jimineep
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