Quick question.
I want to perform a linear regression that looks like this:
lm(y ~ x1 + x2 + x3 + x4 +x5, mydata)
This works fine if I manually write out this code.
However, the independent variables that I want to use are stored as a character, like this:
> vars
[1] "x1 + x2 + x3 + x4 +x5"
I tried typing this:
lm(y ~ vars, mydata)
Error in model.frame.default...
But it gives an error!
So then I tried this:
lm(y ~ noquote(vars), mydata)
Error in model.frame.default...
And then this
lm(y ~ print(vars, quote = FALSE), mydata)
Error in model.frame.default...
Anyone have a clue how I can get around this problem? The character string in "vars" is being provided to me by a program upstream, so I can't work around it at that level.
Thanks!