Pivots a crosstab from bhhi_crosstab()
from long form to wide form.
Arguments
- .data
A tibble from
bhhi_crosstab()
- row_var
Variable to show in the rows in output.
- col_var
Variable to show in the columns in output.
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)
#> # A tibble: 4 × 4
#> race Male_coef Female_coef Overall_coef
#> <fct> <dbl> <dbl> <dbl>
#> 1 Hispanic 0.158 0.143 0.151
#> 2 White 0.662 0.653 0.657
#> 3 Black 0.111 0.127 0.119
#> 4 Other 0.0682 0.0769 0.0726