View source: R/tidy_plus_plus.R
tidy_plus_plus | R Documentation |
This function will apply sequentially:
tidy_and_attach()
tidy_disambiguate_terms()
tidy_identify_variables()
tidy_add_contrasts()
tidy_add_reference_rows()
tidy_add_pairwise_contrasts()
tidy_add_estimate_to_reference_rows()
tidy_add_variable_labels()
tidy_add_term_labels()
tidy_add_header_rows()
tidy_add_n()
tidy_remove_intercept()
tidy_select_variables()
tidy_add_coefficients_type()
tidy_detach_model()
tidy_plus_plus(
model,
tidy_fun = tidy_with_broom_or_parameters,
conf.int = TRUE,
conf.level = 0.95,
exponentiate = FALSE,
model_matrix_attr = TRUE,
variable_labels = NULL,
term_labels = NULL,
interaction_sep = " * ",
categorical_terms_pattern = "{level}",
disambiguate_terms = TRUE,
disambiguate_sep = ".",
add_reference_rows = TRUE,
no_reference_row = NULL,
add_pairwise_contrasts = FALSE,
pairwise_variables = all_categorical(),
keep_model_terms = FALSE,
pairwise_reverse = TRUE,
contrasts_adjust = NULL,
emmeans_args = list(),
add_estimate_to_reference_rows = TRUE,
add_header_rows = FALSE,
show_single_row = NULL,
add_n = TRUE,
intercept = FALSE,
include = everything(),
keep_model = FALSE,
tidy_post_fun = NULL,
quiet = FALSE,
strict = FALSE,
...
)
model |
(a model object, e.g. |
tidy_fun |
( |
conf.int |
( |
conf.level |
( |
exponentiate |
( |
model_matrix_attr |
( |
variable_labels |
( |
term_labels |
( |
interaction_sep |
( |
categorical_terms_pattern |
( |
disambiguate_terms |
( |
disambiguate_sep |
( |
add_reference_rows |
( |
no_reference_row |
( |
add_pairwise_contrasts |
( |
pairwise_variables |
( |
keep_model_terms |
( |
pairwise_reverse |
( |
contrasts_adjust |
( |
emmeans_args |
( |
add_estimate_to_reference_rows |
( |
add_header_rows |
( |
show_single_row |
( |
add_n |
( |
intercept |
( |
include |
( |
keep_model |
( |
tidy_post_fun |
( |
quiet |
( |
strict |
( |
... |
other arguments passed to |
tidy_post_fun
is applied to the result at the end of tidy_plus_plus()
and receive only one argument (the result of tidy_plus_plus()
). However,
if needed, the model is still attached to the tibble as an attribute, even
if keep_model = FALSE
. Therefore, it is possible to use tidy_get_model()
within tidy_fun
if, for any reason, you need to access the source 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_attach_model()
,
tidy_disambiguate_terms()
,
tidy_identify_variables()
,
tidy_remove_intercept()
,
tidy_select_variables()
ex1 <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris) |>
tidy_plus_plus()
ex1
df <- Titanic |>
dplyr::as_tibble() |>
dplyr::mutate(
Survived = factor(Survived, c("No", "Yes"))
) |>
labelled::set_variable_labels(
Class = "Passenger's class",
Sex = "Gender"
)
ex2 <- glm(
Survived ~ Class + Age * Sex,
data = df, weights = df$n,
family = binomial
) |>
tidy_plus_plus(
exponentiate = TRUE,
add_reference_rows = FALSE,
categorical_terms_pattern = "{level} / {reference_level}",
add_n = TRUE
)
ex2
if (.assert_package("gtsummary", boolean = TRUE)) {
ex3 <-
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
)
) |>
tidy_plus_plus(
exponentiate = TRUE,
variable_labels = c(age = "Age (in years)"),
add_header_rows = TRUE,
show_single_row = all_dichotomous(),
term_labels = c("poly(age, 3)3" = "Cubic age"),
keep_model = TRUE
)
ex3
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.