It is documented that broom::tidy
can tidy a speedglm
object: https://broom.tidyverse.org/reference/tidy.speedglm.html. In the following examples, broom::tidy
a speedglm
object returns some columns as 'fct' rather than 'dbl'. I guess it happens when there are one or more scientific notations in the column. I have tried to change option(digits = #, scipen = #)
with no luck. Any suggestions would be appreciated.
library(broom)
library(speedglm)
#> Loading required package: Matrix
#> Loading required package: MASS
library(chest) # get example data (diab_df)
m1 <- glm(Diabetes ~ Sex + Married, family = binomial(), data = diab_df)
tidy(m1) # works fine
#> # A tibble: 3 x 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) -0.803 0.157 -5.13 0.000000287
#> 2 Sex 0.0958 0.0925 1.04 0.300
#> 3 Married -0.0000364 0.0908 -0.000401 1.000
m2 <- speedglm(Diabetes ~ Sex + Married, family = binomial(), data = diab_df)
tidy(m2) # returns <fct> for values with scintific notation: `estimate` and `p.value`
#> # A tibble: 3 x 5
#> term estimate std.error statistic p.value
#> <chr> <fct> <dbl> <dbl> <fct>
#> 1 (Intercept) -8.034e-01 0.157 -5.13 2.87e-07
#> 2 Sex " 9.578e-02" 0.0925 1.04 3.00e-01
#> 3 Married -3.640e-05 0.0908 -0.0004 1.00e+00
Created on 2019-12-18 by the reprex package (v0.3.0)