Skip to contents

Creates a formatted table via the gt package from a survey crosstab that has been reshaped via bhhi_reshape_crosstab().

Usage

bhhi_format_crosstab(.data, decimals = 1)

Arguments

.data

A tibble from bhhi_reshape_crosstab()

decimals

An integer specifing the number of decimal places in the results. Defaults to 1.

Examples

data("nhanes", package = "survey")

survey_object <- nhanes |>
  dplyr::rename(gender = RIAGENDR) |>
  dplyr::mutate(
    gender = factor(gender, 1:2, c("Male", "Female")),
    race = factor(race, 1:4, c("Hispanic", "White", "Black", "Other"))
  ) |>
  srvyr::as_survey(weights = WTMEC2YR)

survey_object |>
  bhhi_crosstab(race, gender) |>
  bhhi_reshape_crosstab(race, gender) |>
  bhhi_format_crosstab()