Creates a chi.squared test table for multiple dependent variables

nice_chi_test_table(
  dv,
  iv,
  data,
  conditions = levels(factor(iv))[1:2],
  ref_levels = 2,
  labels = NULL,
  nice_p = TRUE,
  digits = 2,
  order = "12",
  label_attr = TRUE,
  type = "html",
  ...
)

chi_test_table(...)

Arguments

dv

A data frame with the dependent variables or a character vector when argument data is set.

iv

A data frame or vector with the independent variable or a character if argument data is set.

data

A data frame.

conditions

A character vector of length two with the names of the two conditions. Defaults to the first two levels of the independent variable 'iv' if applicable.

ref_levels

Vector with the reference level for each dependent variable. Values are repeated if length of levels vector is smaller than number dependent variables.

labels

A character vector of length two with labels for the dependent variables.

nice_p

If TRUE, p values are printed in a nice format.

digits

Number of digits for rounding mean and sd values

order

Either "12" or "21" depicting whether group two is compared to group one or vice versa.

type

Either "df" for data frame or "html" for html table.

...

Further arguments passed to nice_table()

Value

A tibble or an html table

Examples

dat <- data.frame(
  gender = factor(rbinom(100, 1, 0.3), labels = c("male", "female")),
  glasses = factor(rbinom(100, 1, 0.3), labels = c("no", "yes")),
  sen = factor(rbinom(100, 1, 0.5), labels = c("no_sen", "sen"))
 )
chi_test_table(
  c("gender", "glasses"), "sen", data = dat, 
  ref_levels = c("male", "no")
)
Table
Chi-squared test
Variable Level
Proportion
X²(1) p
n
no_sen sen Difference no_sen sen
gender male 0.74 0.68 0.06 0.19 .659 50 50
glasses no 0.78 0.72 0.06 0.21 .644 50 50
Note. One degree of freedom for all tests.