|
Hello,
Can someone point out what is wrong with the
following program?
> for ( i in 1:5)
assign(paste("var",i,sep=""),(5*i+13)/18)
I then want to access the variable of the name
"vari". Since 'i' is inside the quotes and will not be evaluated, I
consider
> for (i in 1:5)
vec<-c(get(paste("var",i,sep=""))) > vec [1]
2.111111
Why only the last value i.e.
var5 is printed while I am expecting a vector of length 5?
Next, I successfully tried
> for (i in 1:5) print(get(paste("var",i,sep=""))) [1] 1 [1]
1.277778 [1] 1.555556 [1] 1.833333 [1] 2.111111 >
Why the print() function works and
not <- ?
RH
|