Counts and percentages across grouping variables.

cat_counter(data, x, y = NULL, ...)

Arguments

data

A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.

x

The variable to use as the rows in the contingency table.

y

The variable to use as the columns in the contingency table. Default is NULL. If NULL, one-sample proportion test (a goodness of fit test) will be run for the x variable. Otherwise an appropriate association test will be run. This argument can not be NULL for ggbarstats function.

...

Additional grouping variables.

Examples

ggstatsplot:::cat_counter(data = ggplot2::mpg, "drv", cyl, "fl")
#> # A tibble: 22 x 5 #> cyl drv fl counts perc #> <int> <chr> <chr> <int> <dbl> #> 1 6 r r 4 100 #> 2 8 r e 1 4.76 #> 3 8 r p 7 33.3 #> 4 8 r r 13 61.9 #> 5 4 f c 1 1.72 #> 6 4 f d 3 5.17 #> 7 4 f p 14 24.1 #> 8 4 f r 40 69.0 #> 9 5 f r 4 100 #> 10 6 f e 1 2.33 #> # ... with 12 more rows