validate_df {collinear} | R Documentation |
Validate input data frame
Description
Internal function to validate and prepare the input data frame for a multicollinearity analysis.
Validates a data frame to ensure it complies with the requirements of the package functions. The function 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.
Raise warning if number of rows of 'df' is lower than 'min_rows'.
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, min_rows = 30)
Arguments
df |
(required; data frame or matrix) Input data frame. Default: NULL |
min_rows |
(required; integer) Minimum number of rows required for a pairwise correlation or a variance inflation factor analysis. Default: 30 |
Value
The input data frame modified to comply with the requirements of the functions in this package
Author(s)
Blas M. Benito
Examples
data(vi)
#validating example data frame
vi <- validate_df(
df = vi
)
#tagged as validated
attributes(vi)$validated