Can macros be used in R?
I did look another question similar to this one, but couldn't understand it well.
Let's say I want to create scalars, each with a different name and content. Basically, what I want to run in R can be illustrated by the following dummy example:
local i=1
forvalues i=1/5 {
scalar scalar_`i'=`i'+1
}
In Stata, as i
takes different values, scalar1
, scalar2
, scalar3
etc. are generated. I didn't have to type out the entire list (just i=1/5
) while running the loop.
Can this be done in R?