# Load the Titanic dataset
df <- datasets::Titanic |>
dplyr::as_tibble() |>
# convert aggregated counts to individual observations
dplyr::filter(n > 0) |>
tidyr::uncount(weights = n) |>
# convert character variables to factors
dplyr::mutate(dplyr::across(dplyr::where(is.character), as.factor))
# Perform logistic regression using `glm`
lr <- stats::glm(
data = df,
family = 'binomial',
formula = Survived ~ Class + Sex + Age
)
# Produce the Odds Ratio table as a tibble
table_or(lr)
# Produce the Odds Ratio table as a gt object
table_or(lr, output = 'gt')
Run the code above in your browser using DataLab