FreqTable: Create 2 variable contingency tables.

Description Usage Arguments Value Author(s) Examples

Description

A wrapper using the Mosaic package's tally function to create 2-way contingency tables for two variables.

Usage

1
FreqTable(var1, var2, format = "count")

Arguments

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.

Value

Produces a 2-way contingency table.

Author(s)

Amelia McNamara, James Molyneux

Examples

 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)

mobilizingcs/MobilizePrime documentation built on May 23, 2019, 5:07 a.m.