Skip to contents

Use janitor::tabyl and various adorn_-functions to create a tidy crosstab.

Usage

tidyxtab(data, x, y, row_name = deparse(x), col_name = deparse(y))

Arguments

data

A data.frame.

x

The row-variable

y

The column-variable

row_name, col_name

Passed to janitor::adorn_title.

Value

A janitor::tabyl

Examples

tidyxtab(mtcars, carb, gear)
#>             ~gear                                 
#>  ~carb          3          4         5       Total
#>      1  3  (9.4%)  4 (12.5%) 0  (0.0%)  7  (21.9%)
#>      2  4 (12.5%)  4 (12.5%) 2  (6.3%) 10  (31.3%)
#>      3  3  (9.4%)  0  (0.0%) 0  (0.0%)  3   (9.4%)
#>      4  5 (15.6%)  4 (12.5%) 1  (3.1%) 10  (31.3%)
#>      6  0  (0.0%)  0  (0.0%) 1  (3.1%)  1   (3.1%)
#>      8  0  (0.0%)  0  (0.0%) 1  (3.1%)  1   (3.1%)
#>  Total 15 (46.9%) 12 (37.5%) 5 (15.6%) 32 (100.0%)