I am wondering how to extract the call of a (linear) model in case a formula object is used as input.
For example, the following returns the call:
getCall(lm(mpg ~ am + cyl, data = mtcars))
#> lm(formula = mpg ~ am + cyl, data = mtcars)
However, when I use a formula object then the extracted call returns the name of the object. Is it possible to return the formula itself?
fm <- formula(mpg ~ am + cyl)
getCall(lm(fm, data = mtcars))
#> lm(formula = fm, data = mtcars)
I would like to have the following:
fm <- formula(mpg ~ am + cyl)
getCall(lm(fm, data = mtcars))
#> lm(formula = mpg ~ am + cyl, data = mtcars)
Created on 2021-01-02 by the reprex package (v0.3.0)