View source: R/validate_arg_preference_order.R
| validate_arg_preference_order | R Documentation |
preference_orderInternal function to validate the argument preference_order in cor_select(), vif_select(), collinear_select(), collinear(), and collinear(). Predictors not in preference_order are ranked from lower to higher sum of Pearson correlations with all other predictors.
validate_arg_preference_order(
df = NULL,
response = NULL,
predictors = NULL,
preference_order = NULL,
quiet = FALSE,
function_name = NULL,
...
)
df |
(required; dataframe, tibble, or sf) A dataframe with responses
(optional) and predictors. Must have at least 10 rows for pairwise
correlation analysis, and |
response |
(optional, character string) Name of a numeric response variable in |
predictors |
(optional; character vector or NULL) Names of the
predictors in |
preference_order |
(optional; character vector, dataframe from
|
quiet |
(optional; logical) If FALSE, messages are printed. Default: FALSE. |
function_name |
(optional, character string) Name of the function performing the argument check. Default: NULL |
... |
(optional) Internal args (e.g. |
character vector: ranked variable names
Other argument_validation:
drop_geometry_column(),
validate_arg_df(),
validate_arg_df_not_null(),
validate_arg_encoding_method(),
validate_arg_f(),
validate_arg_function_name(),
validate_arg_max_cor(),
validate_arg_max_vif(),
validate_arg_predictors(),
validate_arg_quiet(),
validate_arg_responses()
data(
vi_smol,
vi_predictors_numeric
)
#input arguments must be validated first
df <- validate_arg_df(
df = vi_smol,
response = "vi_numeric",
predictors = vi_predictors_numeric,
quiet = TRUE
)
response <- validate_arg_responses(
df = df,
responses = "vi_numeric"
)
predictors <- validate_arg_predictors(
df = df,
response = response,
predictors = vi_predictors_numeric[1:10]
)
#no preference order
#no response
#ranks predictor from lower to higher multicollinearity
y <- validate_arg_preference_order(
df = df,
predictors = predictors,
preference_order = NULL
)
y
attributes(y)$validated
#validate character vector
y <- validate_arg_preference_order(
df = df,
predictors = predictors,
preference_order = c(
"swi_max",
"swi_min",
"swi_deviance" #does not exist
)
)
y
attributes(y)$validated
#validate output of preference order
x <- preference_order(
df = df,
responses = response,
predictors = predictors
)
x
y <- validate_arg_preference_order(
df = df,
response = response,
predictors = predictors,
preference_order = x
)
y
attributes(y)$validated
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.