I have a formula:
form <- outcome ~ var1 + var2 + (!is.na(var3) | var3 == "ANY") + (var1:var2)
Let's say the formula has 4 components:
- var1
- var2
- (!is.na(var3) | var3 == "ANY")
- (var1:var2)
I would like to obtain a column for each formula component.
In the case of var1 and var2 it would be easy:
dataset$var1
dataset$var2
I know is possible to use eval(parse(text="(!is.na(var3) | var3 == "ANY")")) with a combination of the with function. But it won't work with some formula expressions (like (var1:var2)).