pubh (version 1.2.7)

cross_tab: Cross-tabulation.

Description

cross_tab is a wrapper to functions from package moonBook to construct tables of descriptive statistics stratified by levels of a categorical outcome.

Usage

cross_tab(
  object = NULL,
  formula = NULL,
  data = NULL,
  label = NULL,
  show.total = TRUE,
  p_val = FALSE,
  pad = 3,
  width = 0.8,
  method = 1,
  ...
)

Value

A huxtable with descriptive statistics stratified by levels of the outcome.

Arguments

object

When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples.

formula

A formula with shape: y ~ x, where y is a categorical outcome and x is the explanatory variable or a set of explanatory variables (see Details and Examples).

data

A data frame where the variables in the formula can be found.

label

A character, label to be used for the outcome (for non-labelled data).

show.total

Logical, show column with totals?

p_val

Logical, show p-values?

pad

Numerical, padding above and bellow rows.

width

Numerical, proportional width of the table.

method

An integer indicating methods for continuous variables. 1 Reports means and standard deviations. 2 Reports medians and interquartile ranges.

...

Additional arguments passed to mytable_sub.

Details

Function cross_tab is a relatively simple wrapper to function mytable of package moonBook. Its main purpose is to construct contingency tables but it can also be used to report a table with descriptives for all variables as long as they are still stratified by the outcome. Please see examples to see how to list explanatory variables. For categorical explanatory variables, the function reports column percentages. If data is labelled with sjlabelled, the label of the outcome (dependent) variable is used to name the outcome; this name can be changed with argument label.

See Also

mytable