Create formula call from character string
问题 I use a best subset selection package to determine the best independent variables from which to build my model (I do have a specific reason for doing this instead of using the best subset object directly). I want to programmatically extract the feature names and use the resulting string to build my model formula. The result would be something like this: x <- "x1 + x2 + x3" y <- "Surv(time, event)" Because I'm building a coxph model, the formula is as follows: coxph(Surv(time, event) ~ x1 + x2