[R] macro facility in R

Michael Prager Mike.Prager at noaa.gov
Mon Jul 3 15:49:51 CEST 2006

Here is one user's perspective on this, with no pretense of being 
definitive.  In the S (R) world, the expression "computing on the 
language" is used to encompass what I would call the tasks of macro 
programming.  This involves uses of various S (R) expressions that 
convert between names of objects and the object themselves; pasting 
together expressions out of fixed and variable text; and executing 
them.  I for one have been able to do everything I could do in the SAS 
macro language, but it has taken trial and error.

To get started, you might consult section 3.5 of S Programming by 
Venables and Ripley.


John Sorkin wrote on 7/3/2006 7:39 AM:
> R 2.2 on windows XP
> I have a dataset with multiple columns. Some of the columns represent
> independent variables, some represent dependent variables. I would like
> to run the same analyses on a fixed set of independent variables,
> changing only the dependent variable, e.g.
> y1-y2=x1+x2+x3
> y3-y4=x1+x2+x3
> y5-y6=x1+x2+x3, etc.
> I know I can write a function to perform the analyses, however in order
> to make the analyses easy to do, I really need a macro scripting
> language that will allow preprocessing of the function and substitution
> of macro variables with parameters passed to the macro, i.e. I need
> someting akin to the macro facility in SAS. Is there a macro facility
> that I can use with R? I have tried help.search("macro") and did not
> have any success.
> Thanks,
> John  
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> Baltimore VA Medical Center GRECC,
> University of Maryland School of Medicine Claude D. Pepper OAIC,
> University of Maryland Clinical Nutrition Research Unit, and
> Baltimore VA Center Stroke of Excellence
> University of Maryland School of Medicine
> Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> 410-605-7119
> jsorkin at grecc.umaryland.edu
> ______________________________________________
> R-help at 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

Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA

More information about the R-help mailing list