validate_predictors | R Documentation |
Internal function to validate the predictors
argument. Requires the argument 'df' to be validated with validate_df()
.
Validates the 'predictors' argument to ensure it complies with the requirements of the package functions. It performs the following actions:
Stops if 'df' is NULL.
Stops if 'df' is not validated.
If 'predictors' is NULL, uses column names of 'df' as 'predictors' in the 'df' data frame.
Print a message if there are names in 'predictors' not in the column names of 'df', and returns only the ones in 'df'.
Stop if the number of numeric columns in 'predictors' is smaller than 'min_numerics'.
Print a message if there are zero-variance columns in 'predictors' and returns a new 'predictors' argument without them.
Tags the vector with the attribute validated = TRUE
to let the package functions skip the data validation.
validate_predictors(
df = NULL,
response = NULL,
predictors = NULL,
quiet = FALSE
)
df |
(required; data frame, tibble, or sf) A data frame with responses and predictors. Default: NULL. |
response |
(optional; character string or vector) Name/s of response variable/s in |
predictors |
(optional; character vector) Names of the predictors to select from |
quiet |
(optional; logical) If FALSE, messages generated during the execution of the function are printed to the console Default: FALSE |
character vector: predictor names
Other data_validation:
validate_data_cor()
,
validate_data_vif()
,
validate_df()
,
validate_encoding_arguments()
,
validate_preference_order()
,
validate_response()
data(
vi,
vi_predictors
)
#validating example data frame
vi <- validate_df(
df = vi
)
#validating example predictors
vi_predictors <- validate_predictors(
df = vi,
predictors = vi_predictors
)
#tagged as validated
attributes(vi_predictors)$validated
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.