knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The broom.helpers package provides suite of functions to work with regression model broom::tidy()
tibbles.
The suite includes functions to group regression model terms by variable, insert reference and header rows for categorical variables, add variable labels, and more.
broom.helpers
is used, in particular, by gtsummary::tbl_regression()
for producing nice formatted tables of model coefficients and by ggstats::ggcoef_model()
for plotting model coefficients.
To install stable version:
install.packages("broom.helpers")
Documentation of stable version: https://larmarange.github.io/broom.helpers/
To install development version:
remotes::install_github("larmarange/broom.helpers")
Documentation of development version: https://larmarange.github.io/broom.helpers/dev/
mod1 <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris) library(broom.helpers) ex1 <- mod1 |> tidy_plus_plus() ex1 dplyr::glimpse(ex1) mod2 <- glm( response ~ poly(age, 3) + stage + grade * trt, na.omit(gtsummary::trial), family = binomial, contrasts = list( stage = contr.treatment(4, base = 3), grade = contr.sum ) ) ex2 <- mod2 |> tidy_plus_plus( exponentiate = TRUE, variable_labels = c(age = "Age (in years)"), add_header_rows = TRUE, show_single_row = "trt" ) ex2 dplyr::glimpse(ex2)
ex3 <- mod1 |> # perform initial tidying of model tidy_and_attach() |> # add reference row tidy_add_reference_rows() |> # add term labels tidy_add_term_labels() |> # remove intercept tidy_remove_intercept() ex3 dplyr::glimpse(ex3) ex4 <- mod2 |> # perform initial tidying of model tidy_and_attach(exponentiate = TRUE) |> # add variable labels, including a custom value for age tidy_add_variable_labels(labels = c(age = "Age in years")) |> # add reference rows for categorical variables tidy_add_reference_rows() |> # add a, estimate value of reference terms tidy_add_estimate_to_reference_rows(exponentiate = TRUE) |> # add header rows for categorical variables tidy_add_header_rows() ex4 dplyr::glimpse(ex4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.