[R] piecing together statements (macro?)

toby909 at gmail.com toby909 at gmail.com
Fri Mar 9 22:46:39 CET 2007


Hi All

I am pretty new to R but saw stata and sas's macro facilities and am looking for 
how such things work in R.

I am trying to piece together a series of statements:


n = 5   #want to have it dynamic with respect to n
for (j in 1:n) {
eval(paste("x", j, "=x[", j, "]", sep=""))
}

I want the created statements 'x1=x[1]' immediately executed and tried to do 
that with eval() but that did not work.

Any hints greatly appreciates.

Thanks Toby



More information about the R-help mailing list