cross_tab
is a wrapper to functions from package moonBook
to construct tables of descriptive statistics stratified by levels of a categorical outcome.
cross_tab(
object = NULL,
formula = NULL,
data = NULL,
label = NULL,
show.total = TRUE,
p_val = FALSE,
pad = 3,
width = 0.8,
method = 1,
...
)
A huxtable with descriptive statistics stratified by levels of the outcome.
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.
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).
A data frame where the variables in the formula
can be found.
A character, label to be used for the outcome (for non-labelled data).
Logical, show column with totals?
Logical, show p-values?
Numerical, padding above and bellow rows.
Numerical, proportional width of the table.
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
.
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
.
mytable