sgaure / lfe

Source code repository for the R package lfe on CRAN.
53 stars 18 forks source link

felm: extract formula? #8

Closed MatthieuStigler closed 5 years ago

MatthieuStigler commented 6 years ago

Hi

It seems formula() does not work directly on a felm object. As x$formula is missing, it returns instead x$terms (unfortunately, returning x$call$formula seems third priority for formula.default). Is it possible to either:

I tried to make a pull request for the first option, but got lost in the code :-(

library(lfe)
#> Loading required package: Matrix
example(felm, echo=FALSE)
formula(est)
#> ~x + x2
#> attr(,"variables")
#> list(x, x2)
#> attr(,"factors")
#>    x x2
#> x  1  0
#> x2 0  1
#> attr(,"term.labels")
#> [1] "x"  "x2"
#> attr(,"order")
#> [1] 1 1
#> attr(,"intercept")
#> [1] 1
#> attr(,"response")
#> [1] 0

Created on 2018-10-12 by the reprex package (v0.2.1)

Thanks!

Matthieu

karldw commented 5 years ago

Hey @MatthieuStigler, I was looking at this issue, and it seems like formula now works as expected.

MatthieuStigler commented 5 years ago

Yes, indeed! Closing the issue

library(lfe)
#> Loading required package: Matrix
packageVersion("lfe")
#> [1] '2.8.3'
example(felm, echo=FALSE)
formula(est)
#> y ~ x + x2 | id + firm

Created on 2019-09-13 by the reprex package (v0.3.0)