Title

tabyl_three_way_flatten(tabyl, list_var = NULL)

Arguments

tabyl

Value

Examples

datasets::Titanic %>% data.frame() %>% janitor::clean_names() %>% tidyr::uncount(weights = freq) %>% janitor::tabyl(survived, class, sex) %>% janitor::adorn_totals(c("row", "col")) %>% janitor::adorn_percentages(denominator = "col") %>% janitor::adorn_pct_formatting() %>% janitor::adorn_ns(position = "front") %>% tabyl_three_way_flatten()
#> cat survived 1st 2nd 3rd Crew #> 1 Male No 118 (65.6%) 154 (86.0%) 422 (82.7%) 670 (77.7%) #> 2 Male Yes 62 (34.4%) 25 (14.0%) 88 (17.3%) 192 (22.3%) #> 3 Male Total 180 (100.0%) 179 (100.0%) 510 (100.0%) 862 (100.0%) #> 4 Female No 4 (2.8%) 13 (12.3%) 106 (54.1%) 3 (13.0%) #> 5 Female Yes 141 (97.2%) 93 (87.7%) 90 (45.9%) 20 (87.0%) #> 6 Female Total 145 (100.0%) 106 (100.0%) 196 (100.0%) 23 (100.0%) #> Total #> 1 1364 (78.8%) #> 2 367 (21.2%) #> 3 1731 (100.0%) #> 4 126 (26.8%) #> 5 344 (73.2%) #> 6 470 (100.0%)
datasets::Titanic %>% data.frame() %>% janitor::clean_names() %>% tidyr::uncount(weights = freq) %>% janitor::tabyl(survived, class, sex) %>% janitor::adorn_totals(c("row", "col")) %>% tabyl_three_way_flatten(list_var = "sex")
#> sex survived 1st 2nd 3rd Crew Total #> 1 Male No 118 154 422 670 1364 #> 2 Male Yes 62 25 88 192 367 #> 3 Male Total 180 179 510 862 1731 #> 4 Female No 4 13 106 3 126 #> 5 Female Yes 141 93 90 20 344 #> 6 Female Total 145 106 196 23 470