To facilitate the use of broom helpers with pipe, it is recommended to
attach the original model as an attribute to the tibble of model terms
generated by broom::tidy()
.
tidy_attach_model(x, model, .attributes = NULL)
tidy_and_attach(
model,
tidy_fun = tidy_with_broom_or_parameters,
conf.int = TRUE,
conf.level = 0.95,
exponentiate = FALSE,
...
)
tidy_get_model(x)
tidy_detach_model(x)
a tibble of model terms
a model to be attached/tidied
named list of additional attributes to be attached to x
option to specify a custom tidier function
logical indicating whether or not to include a confidence interval in the tidied output
level of confidence for confidence intervals (default: 95%)
logical indicating whether or not to exponentiate the
coefficient estimates. This is typical for logistic, Poisson and Cox models,
but a bad idea if there is no log or logit link; defaults to FALSE
other arguments passed to tidy_fun()
tidy_attach_model()
attach the model to a tibble already generated while
tidy_and_attach()
will apply broom::tidy()
and attach the model.
Use tidy_get_model()
to get the model attached to the tibble and
tidy_detach_model()
to remove the attribute containing the model.
Other tidy_helpers:
tidy_add_coefficients_type()
,
tidy_add_contrasts()
,
tidy_add_estimate_to_reference_rows()
,
tidy_add_header_rows()
,
tidy_add_n()
,
tidy_add_pairwise_contrasts()
,
tidy_add_reference_rows()
,
tidy_add_term_labels()
,
tidy_add_variable_labels()
,
tidy_disambiguate_terms()
,
tidy_identify_variables()
,
tidy_plus_plus()
,
tidy_remove_intercept()
,
tidy_select_variables()
mod <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris)
tt <- mod %>%
tidy_and_attach(conf.int = TRUE)
tt
#> # A tibble: 4 × 7
#> term estimate std.error statistic p.value conf.low conf.high
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 2.25 0.370 6.09 9.57e- 9 1.52 2.98
#> 2 Sepal.Width 0.804 0.106 7.56 4.19e-12 0.593 1.01
#> 3 Speciesversicolor 1.46 0.112 13.0 3.48e-26 1.24 1.68
#> 4 Speciesvirginica 1.95 0.100 19.5 2.09e-42 1.75 2.14
tidy_get_model(tt)
#>
#> Call:
#> lm(formula = Sepal.Length ~ Sepal.Width + Species, data = iris)
#>
#> Coefficients:
#> (Intercept) Sepal.Width Speciesversicolor Speciesvirginica
#> 2.2514 0.8036 1.4587 1.9468
#>