Description Usage Arguments Value Author(s) Examples
A wrapper using the Mosaic package's tally function to create 2-way contingency tables for two variables.
1 |
var1 |
the first variable for the table. |
var2 |
the second variable for the table. If not supplied a table with the counts of var1 will be created. |
format |
users can decide whether to display the table as counts, percents or proportions by using 'count', 'percent' or 'proportion'. Default is to use 'count'. |
totals |
logical. Users can either have the totals calculated by setting totals = TRUE or leave them out by setting totals = FALSE. |
Produces a 2-way contingency table.
Amelia McNamara, James Molyneux
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 1-way contingency table
FreqTable(mtcars$gear)
# 2-way contingency table
FreqTable(mtcars$gear, mtcars$cyl)
# Different formats for 2-way contingency table
FreqTable(mtcars$gear, mtcars$cyl, format = 'count')
FreqTable(mtcars$gear, mtcars$cyl, format = 'percent')
FreqTable(mtcars$gear, mtcars$cyl, format = 'proportion')
# Turn 'totals' off
FreqTable(mtcars$gear, mtcars$cyl, totals = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.