validate_columns | R Documentation |
This function ensures that the imported data contains all required columns, optionally removes unwanted extra columns, and provides informative messages about the dataset's structure.
validate_columns(
data,
extra_columns = NULL,
drop_extra = FALSE,
silent = FALSE
)
data |
A data frame containing the imported matrix. |
extra_columns |
A character vector of allowed additional columns beyond the required ones. Defaults to NULL. |
drop_extra |
A logical value indicating whether to remove extra columns that are not in 'extra_columns'. Defaults to FALSE. |
silent |
A logical value indicating whether to suppress messages. Defaults to FALSE. |
The function checks whether all required columns are present in the data. If any required columns are missing, it stops execution and informs the user.
It also identifies extra columns beyond the required set and compares them against the allowed 'extra_columns'. If 'drop_extra = TRUE', it removes any extra columns not listed in 'extra_columns'. If 'drop_extra = FALSE', it retains the extra columns but issues a message unless 'silent = TRUE'.
A cleaned data frame with required columns intact and, optionally, extra columns removed.
The function assumes that column names in 'data' are correctly formatted and case-sensitive.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.