cross_tabyl
cross_tabyl.Rd
cross_tabyl() is a helper function to quickly create a cross-tabulation of the values in a categorical variable.
Examples
# not run
library(dplyr)
cross_tabyl(starwars, "hair_color")
#> # A tibble: 14 × 4
#> `Variable = hair_color` N Percent `Valid Percent`
#> <chr> <dbl> <chr> <chr>
#> 1 auburn 1 1.1% 1.2%
#> 2 auburn, grey 1 1.1% 1.2%
#> 3 auburn, white 1 1.1% 1.2%
#> 4 black 13 14.9% 15.9%
#> 5 blond 3 3.4% 3.7%
#> 6 blonde 1 1.1% 1.2%
#> 7 brown 18 20.7% 22.0%
#> 8 brown, grey 1 1.1% 1.2%
#> 9 grey 1 1.1% 1.2%
#> 10 none 37 42.5% 45.1%
#> 11 unknown 1 1.1% 1.2%
#> 12 white 4 4.6% 4.9%
#> 13 NA 5 5.7% -
#> 14 Total Queries 87 - -
cross_tabyl(starwars, "name")
#> # A tibble: 88 × 3
#> `Variable = name` N Percent
#> <chr> <dbl> <chr>
#> 1 Ackbar 1 1.1%
#> 2 Adi Gallia 1 1.1%
#> 3 Anakin Skywalker 1 1.1%
#> 4 Arvel Crynyd 1 1.1%
#> 5 Ayla Secura 1 1.1%
#> 6 BB8 1 1.1%
#> 7 Bail Prestor Organa 1 1.1%
#> 8 Barriss Offee 1 1.1%
#> 9 Ben Quadinaros 1 1.1%
#> 10 Beru Whitesun lars 1 1.1%
#> # … with 78 more rows