cattab.Rd
Computes bivariate statistics for a set of variables according to the subgroups of observations defined by a categorical variable.
cattab(x, y, weights = NULL, percent = "column",
robust = TRUE, show.n = TRUE, show.asso = TRUE,
digits = c(1,1), na.rm = TRUE, na.value = "NAs")
data frame. The variables which are described in rows. They can be numerical or factors.
factor. The categorical variable which defines subgroups of observations described in columns.
numeric vector of weights. If NULL (default), uniform weights (i.e. all equal to 1) are used.
character. Whether to compute row percentages ("row") or column percentages ("column", default).
logical. Whether to use medians instead of means. Default is TRUE.
logical. Whether to display frequencies (between brackets) in addition to the percentages. Default is TRUE.
logical. Whether to add a column with measures of global association (Cramer's V and eta-squared). Default is TRUE.
vector of 2 integers. The first value sets the number of digits for percentages, the second one sets the number of digits for medians and means. Default is c(1,1). If NULL, the results are not rounded.
logical, indicating whether NA values should be silently removed before the computation proceeds. If FALSE (default), an additional level is added to the variables (see na.value
argument).
character. Name of the level for NA category. Default is "NAs". Only used if na.rm = FALSE.
The function uses gtsummary
package to build the table of statistics, and then gt
package to finalize the layout. Weights are handled silently with survey
package.
Besides, the function is compatible with the attribute labels assigned with labelled
package : these labels are displayed automatically.
This function is quite similar to profiles
, but displays the results in a fancier way.
An object of class gt_tbl
.