How do I assign a macro variable in R?
In SAS, I would use the following code
%LET DEPVAR = sales_ind
PROC REG DATA=mydata;
MODEL &DEPVAR = VAR1
None of them works. The macro variable is invoked with & in SAS but no similar & being used in R although you can use new=as.name("f3") or new=quote(f3) to refer to f3 as shown below.
> test<-data.frame(f1=c(1,2), f2=c("a","b")); test
# f1 f2
#1 1 a
#2 2 b
> new=as.name("f3"); new;
#f3
> new=quote(f3); new;
#f3
> # you still get new rather than f3 as expected
> new<-test$f1;
> new
#[1] 1 2