Displaying 2 results from an estimated 2 matches for "create_var_names".
2008 Aug 12
5
produce variable on the fly
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
2009 Apr 18
4
Loop question
Hi everyone, I am trying to accomplish a small task that is giving me
quite a headache. I would like to automatically generate a series of
matrices and give them successive names. Here is what I thought at
first:
t1<-matrix(0, nrow=250, ncol=1)
for(i in 1:10){
t1[i]<-rnorm(250)
}
What I intended was that the loop would create 10 different matrices
with a single column of 250