contingency_table {kim}R Documentation

Contingency table

Description

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".

Examples

contingency_table(
data = mtcars,
row_var_name = "am",
col_var_name = "cyl")
contingency_table(row = mtcars$cyl, col = mtcars$am)
contingency_table(mtcars, "am", "cyl", output_type = "dt")

[Package kim version 0.5.422 Index]