I'm trying to do something like the following:
control_set_1 = "education + income + sex + birth + race + trust_daily"
control_set_2 = "sex + birth + race + trust_daily"
fit_controls <- lm(data = data, dv ~ politics*treatment + control_set_1)
fit_controls_2 <- lm(data = data, dv ~ politics*treatment + control_set_2)
I have tried wrapping control_set_1
in as.formula(control_set_1)
, to no avail.
I get the error:
Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data, : variable lengths differ (found for 'control_set_1')
What is the right way to do this?