Cross Tabulate Counts
cross_tab.RdCreate a contingency table of counts generated
by cross-classifying factors from groups
splitting on the values passed in the ... argument.
A thin wrapper around table() but with simplifying
features. The sums of each row and column are added to the result.
Examples
# 1 factor
cross_tab(mtcars, cyl)
#> cyl
#> 4 6 8 Sum
#> 11 7 14 32
# 2 factors
cross_tab(mtcars, cyl, gear)
#> gear
#> cyl 3 4 5 Sum
#> 4 1 8 2 11
#> 6 2 4 1 7
#> 8 12 0 2 14
#> Sum 15 12 5 32
if (FALSE) { # \dontrun{
# No quoted strings (!)
cross_tab(mtcars, "cyl")
# No external variable (!)
var <- "cyl"
cross_tab(mtcars, var)
} # }