bivar_table: Bivariate Table

Description Usage Arguments Value Examples

Description

Create a table that shows how a binary field distributes along another discrete variable. Supports all unique values in a variable, custom cut functions, or has a limited number of created helper cut functions for continious variables.

Usage

1
2
bivar_table(x, var, bivar, extra_vars = NULL, cut_fmt = NULL,
  na_last = FALSE, decreasing = FALSE)

Arguments

x

a data.frame or data.table object.

var

a variable to break up the data, either all unique levels will be used, or binned levels if a cut_fmt is chosen.

bivar

a binary performance vector to destribute along var

extra_vars

extra binary variables to distribute in addition to the bivar.

cut_fmt

a function used to cut a numeric column into descrete levels to use in the table. Default is set to NULL. cut_fmt supports the following predefined functions:

  • Set cut_fmt = "decile" to cut the numeric column into decile breaks.

  • Set cut_fmt = "quantile" to cut the numneric column into quantile breaks.

na_last

set to TRUE to have any NA values that may be present in the provided columns to be placed in the last row of the bivariate table. Default is set to FALSE.

decreasing

if set to TRUE the unique levels of the columns will be presented in a decreasing order. Default is set to FALSE.

Value

A bivariate table with the performance field distributed along the levels of the selected variable.

Examples

1
2
3
4
5
6
7
8
# Create a bivariate of vs by cyl
bivar_table(x = mtcars, var = "cyl", bivar = "vs")

# add extra variable am
bivar_table(x = mtcars, var = "cyl", bivar = "vs", extra_vars = "am")

# Use custom predifined cut function
bivar_table(x = mtcars, var = "mpg", bivar = "vs", extra_vars = "am", cut_fmt = "quantile")

jinlow/report.tools documentation built on June 2, 2019, 10:55 p.m.