biv_quali: Bivariate table for categorical data.

View source: R/tables_bivariate.R

biv_qualiR Documentation

Bivariate table for categorical data.

Description

Bivariate table for categorical data.

Usage

biv_quali(
  x = NULL,
  y = NULL,
  xname = NULL,
  yname = NULL,
  totals = TRUE,
  tot_row_label = "Tot",
  tot_col_label = "Tot",
  useNA = "ifany",
  perc = c("col", "row", "none"),
  exclude_NA_perc = TRUE,
  NA_string = "NA",
  freq_sorting = c(NA, "desc", "asc"),
  test = c("auto", "none", "fisher", "chisq", "mcnemar"),
  test_params = list(),
  latex = TRUE,
  latex_placement = "ht",
  label_prefix = "",
  label = "",
  caption_prefix = "",
  caption = "",
  wb = NULL,
  sheets = ""
)

Arguments

x

row variable: a discrete quantitative variable, a character or a factor

y

column variable: a discrete quantitative variable, a character or a factor

xname

a string used to identify x variable (used for latex captions and excel sheets)

yname

a string used to identify x variable (used for latex captions and excel sheets)

totals

print totals?

tot_row_label

label for rows total

tot_col_label

label for columns total

useNA

print NA?

perc

type of percentages

exclude_NA_perc

remove NA from percentages (default = TRUE)

NA_string

character used for NA's columns title

freq_sorting

freq based sorting: can be NA (no freq based sorting) "desc" (descending) or "asc" (ascending). Sorting based on row totals.

test

one of 'auto', 'none', 'fisher', 'chisq', 'mcnemar': if auto (default) fisher or chi square test will be performed (using fisher_needed to decide which one)

test_params

a list of parameters to be passed to the test performing function

latex

output the table using xtable::xtable

latex_placement

table placement for latex printing

label_prefix

latex label prefix (useful for a common prefix in univariate_tables and multivariate_tables). It's ignored if label is specified (eg the latter is considered full/complete/correct)

label

latex label

caption_prefix

a prefix for latex caption (useful for a common prefix in univariate_tables and multivariate_tables)

caption

latex caption

wb

an openxlsx Workbook; if not NULL the table will be saved in the workbook too, aside printing

sheets

optional sheet names (same length as the number of tables)

Examples

x <- airquality$Ozone < 80
y <- airquality$Month 
biv_quali(x = x, y = y, latex = FALSE, test = 'none')
biv_quali(x = x, y = y, latex = FALSE, test = 'none', freq_sort = 'asc')
biv_quali(x = x, y = y, latex = FALSE, test = 'none', freq_sort = 'desc')
biv_quali(x = x, y = y, latex = FALSE, test = 'none', perc = FALSE )

lbraglia/lbstat documentation built on Sept. 17, 2023, 2:30 p.m.