add_var {tidysummary} | R Documentation |
Prepare variables for add_summary
Description
This function processes a dataset for statistical analysis by categorizing variables into continuous and categorical types. It automatically handles normality checks, equality of variances checks, and expected frequency assumptions checks.
Usage
add_var(data, var = NULL, group = "group", norm = "auto", center = "median")
Arguments
data |
A data frame containing the variables to analyze, with variables at columns and observations at rows. |
var |
A character vector of variable names to include. If |
group |
A character string specifying the grouping variable in |
norm |
Control parameter for normality tests. Accepts:
|
center |
A character string specifying the |
Value
A modified data frame with an attribute 'add_var'
containing a list of categorized variables and their properties:
-
var
: List of categorized variables:-
valid
: All valid variable names after checks -
continuous
: Sublist of continuous variables (further divided by normality/equal variance) -
categorical
: Sublist of categorical variables (further divided by ordered/expected frequency)
-
-
group
: Grouping variable name -
overall_n
: Total number of observations -
group_n
: Observation counts per group -
group_nlevels
: Number of groups -
group_levels
: Group level names -
norm
: Normality check method used
Examples
data <- add_var(iris, var = c("Sepal.Length", "Species"), group = "Species")