if (FALSE) { # interactive()
if (.assert_package("gtsummary", boolean = TRUE)) {
df <- Titanic |>
dplyr::as_tibble() |>
dplyr::mutate(Survived = factor(Survived, c("No", "Yes")))
res <-
glm(
Survived ~ Class + Age + Sex,
data = df, weights = df$n, family = binomial,
contrasts = list(Age = contr.sum, Class = "contr.SAS")
) |>
tidy_and_attach()
res |> tidy_add_reference_rows()
res |> tidy_add_reference_rows(no_reference_row = all_dichotomous())
res |> tidy_add_reference_rows(no_reference_row = "Class")
glm(
response ~ stage + grade * trt,
gtsummary::trial,
family = binomial,
contrasts = list(
stage = contr.treatment(4, base = 3),
grade = contr.treatment(3, base = 2),
trt = contr.treatment(2, base = 2)
)
) |>
tidy_and_attach() |>
tidy_add_reference_rows()
}
}
Run the code above in your browser using DataLab