Create a contingency table that takes two variables as inputs
Usage
contingency_table(
data = NULL,
row_var_name = NULL,
col_var_name = NULL,
row = NULL,
col = NULL,
output_type = "table"
)
Arguments
data
a data object (a data frame or a data.table)
row_var_name
name of the variable whose values will fill the
rows of the contingency table
col_var_name
name of the variable whose values will fill the
columns of the contingency table
row
a vector whose values will fill the rows of the
contingency table
col
a vector whose values will fill the columns of the
contingency table
output_type
If output_type == "dt" the output will be a
contingency table as a data.table object.
If output_type == "table" the output will be a contingency table
as a table object.
If output_type == "df" the output will be a contingency
table as a data.frame object.
By default, output_type == "table".