How to use reference variables by character string in a formula?
问题 In the minimal example below, I am trying to use the values of a character string vars in a regression formula. However, I am only able to pass the string of variable names (\"v2+v3+v4\") to the formula, not the real meaning of this string (e.g., \"v2\" is dat$v2). I know there are better ways to run the regression (e.g., lm(v1 ~ v2 + v3 + v4, data=dat) ). My situation is more complex, and I am trying to figure out how to use a character string in a formula. Any thoughts? Updated below code #