[R] Programming/scripting with "expressions - variables"

Gorjanc Gregor Gregor.Gorjanc at bfro.uni-lj.si
Mon Feb 7 15:52:42 CET 2005


Hello to Rusers!

I am puzzled with R and I really do not know where to look
in for my problem. I am moving from SAS and I have difficulties
in translating SAS to R world. I hope I will get some hints 
or pointers so I can study from there on.

I would like to do something like this. In SAS I can write 
a macro as example bellow, which is afcourse a silly one but 
shows what I don't know how to do in R.

%macro test(data, colname, colvalue);
    data &data;
        ...
        &colname="&colvalue";
        other_&colname="other_&colvalue";
    run;
%mend;

And if I run it with this call:
%test(Gregor, Gorjanc, 25);

I get a table with name 'Gregor' and columns 'Gorjanc', 
and 'other_Gorjanc' with values:

Gorjanc other_Gorjanc
"25"    "other_25"

So can one show me the way to do the same thing in R? 

Thanks!

--
Lep pozdrav / With regards,
    Gregor GORJANC

---------------------------------------------------------------
University of Ljubljana
Biotechnical Faculty       URI: http://www.bfro.uni-lj.si
Zootechnical Department    email: gregor.gorjanc <at> bfro.uni-lj.si
Groblje 3                  tel: +386 (0)1 72 17 861
SI-1230 Domzale            fax: +386 (0)1 72 17 888
Slovenia




More information about the R-help mailing list