Reputation: 1211
I am using subset selection methods in the leaps package. After running subset selection, I can get the formula by accessing the $call
variable stored in the object that I ran my subset selection (for this example, let's call the object k
.
So if I run k$call
, it will return a linear model formula, such as:
lm(formula = y + x1 + x2 + x3, data = trainingData)
Is there a way to run this formula by using k$call
?
I tried running lm.1 <- k$call
but it just stores the k$call
instead of making the actual linear regression.
Upvotes: 2
Views: 303
Reputation: 23608
You need to evaluate the expression.
eval(k$call)
will run the call
in your case
lm.1 <- evalk$call
Upvotes: 1