validate - asserts the following:
outcomesmust have 1 column. Atomic vectors are treated as 1 column matrices.
check - returns the following:
okA logical. Does the check pass?n_colsA single numeric. The actual number of columns.
Value
validate_outcomes_are_univariate() returns outcomes invisibly.
check_outcomes_are_univariate() returns a named list of two components,
ok and n_cols.
Details
The expected way to use this validation function is to supply it the
$outcomes element of the result of a call to mold().
Validation
hardhat provides validation functions at two levels.
check_*(): check a condition, and return a list. The list always contains at least one element,ok, a logical that specifies if the check passed. Each check also has check specific elements in the returned list that can be used to construct meaningful error messages.validate_*(): check a condition, and error if it does not pass. These functions call their corresponding check function, and then provide a default error message. If you, as a developer, want a different error message, then call thecheck_*()function yourself, and provide your own validation function.
See also
Other validation functions:
validate_column_names(),
validate_no_formula_duplication(),
validate_outcomes_are_binary(),
validate_outcomes_are_factors(),
validate_outcomes_are_numeric(),
validate_prediction_size(),
validate_predictors_are_numeric()
Examples
validate_outcomes_are_univariate(data.frame(x = 1))
try(validate_outcomes_are_univariate(mtcars))
#> Error in validate_outcomes_are_univariate(mtcars) :
#> The outcome must be univariate, but 11 columns were found.
