Summary table for comparative analysis between two categorical variables
stat_two_cat.Rd
Create a frequency table with chi-square statistic, p-value, cramer's v.
Examples
mtcars %>%
dplyr::mutate(vs = paste0("vs = ",vs)) %>%
stat_two_cat(grp_var = vs,vars = c(am,cyl))
#> Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
#> ℹ Please specify a name for each selection.
#> ℹ Did you want `data = -name`?
#> ℹ The deprecated feature was likely used in the relper package.
#> Please report the issue to the authors.
#> Warning: There were 2 warnings in `dplyr::mutate()`.
#> The first warning was:
#> ℹ In argument: `chi_square = purrr::map(.x = data, .f =
#> ~stats::chisq.test(.$grp_var, .$value))`.
#> Caused by warning in `stats::chisq.test()`:
#> ! Chi-squared approximation may be incorrect
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning.
#> Warning: There was 1 warning in `dplyr::mutate()`.
#> ℹ In argument: `dplyr::across(.fns = ~dplyr::if_else(is.na(.), "-",
#> as.character(.)))`.
#> Caused by warning:
#> ! Using `across()` without supplying `.cols` was deprecated in dplyr 1.1.0.
#> ℹ Please supply `.cols` instead.
Levels
vs = 0
vs = 1
Statistic
P-value
Cramer's V
am
cyl