Skip to contents

Internal function to validate the argument df and ensure it complies with the requirements of the package functions. It performs the following actions:

  • Stops if 'df' is NULL.

  • Stops if 'df' cannot be coerced to data frame.

  • Stops if 'df' has zero rows.

  • Removes geometry column if the input data frame is an "sf" object.

  • Removes non-numeric columns with as many unique values as rows df has.

  • Converts logical columns to numeric.

  • Converts factor and ordered columns to character.

  • Tags the data frame with the attribute validated = TRUE to let the package functions skip the data validation.

Usage

validate_df(df = NULL, quiet = FALSE)

Arguments

df

(required; data frame, tibble, or sf) A data frame with responses and predictors. Default: NULL.

quiet

(optional; logical) If FALSE, messages generated during the execution of the function are printed to the console Default: FALSE

Value

data frame

Examples


data(vi)

#validating example data frame
vi <- validate_df(
  df = vi
)

#tagged as validated
attributes(vi)$validated
#> [1] TRUE