[R] using index of a loop as a macro variable

From: E. Michael Foster <foster_at_pop.psu.edu>
Date: Tue 05 Jul 2005 - 06:31:50 EST


Hi,

I'm a long-time STATA user and a R newbie. I'm doing ok, but I'm addicted to STATA macro variables. Is there something like a macro variable in R?

Specifically, I'd like to be able to do something like

for (i in 1:3) {

	.....
	x`i' <- ...

}

where R would resolve x`i' to the objects named x1, x2 and x3 as I move through the loop. I guess I could create these in advance of the loop and fill them in, but I'd rather not.

Is there a way to use an index of a loop in this manner?

thanks,
michael

E. Michael Foster
Professor of Maternal and Child Health
School of Public Health
University of North Carolina



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 05 06:36:30 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:12 EST