This function prints the results of a calculated two-way frequency table.
# S3 method for crosstab
print(x, ...)
An object of class crosstab
not currently used.
No return value, called for side effects
mycrosstab <- crosstab(mtcars, cyl, gear, type = "freq", digits = 2)
print(mycrosstab)
#> gear
#> cyl 3 4 5 Total
#> 4 1 8 2 11
#> 6 2 4 1 7
#> 8 12 0 2 14
#> Total 15 12 5 32
mycrosstab <- crosstab(mtcars, cyl, gear, type = "rowpercent", digits = 3)
print(mycrosstab)
#> gear
#> cyl 3 4 5 Total
#> 4 9.091% 72.727% 18.182% 100.000%
#> 6 28.571% 57.143% 14.286% 100.000%
#> 8 85.714% 0.000% 14.286% 100.000%