View source: R/identify_categorical_variables.R
| identify_categorical_variables | R Documentation |
Identifies valid and invalid character or factor variables. Invalid categorical predictors are those with a single category, or as many categories as cases (full-cardinality).
identify_categorical_variables(
df = NULL,
responses = NULL,
predictors = NULL,
quiet = FALSE,
...
)
df |
(required; dataframe, tibble, or sf) A dataframe with responses
(optional) and predictors. Must have at least 10 rows for pairwise
correlation analysis, and |
responses |
(optional; character, character vector, or NULL) Name of
one or several response variables in |
predictors |
(required, character vector) Names of the predictors to identify. Default: NULL |
quiet |
(optional; logical) If FALSE, messages are printed. Default: FALSE. |
... |
(optional) Internal args (e.g. |
list:
valid: character vector with valid categorical predictor names.
invalid: character vector with invalid categorical predictor names due to degenerate cardinality (1 or nrow(df) categories).
Blas M. Benito, PhD
Other data_types:
identify_logical_variables(),
identify_numeric_variables(),
identify_response_type(),
identify_valid_variables(),
identify_zero_variance_variables()
data(vi_smol, vi_predictors)
#create an invalid categorical
vi_smol$invalid_categorical <- "a"
x <- identify_categorical_variables(
df = vi_smol,
responses = "vi_categorical",
predictors = vi_predictors
)
x$valid
x$invalid
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.