validate_outcomes_are_binary: Ensure that the outcome has binary factors

Description Usage Arguments Details Value Validation See Also Examples

View source: R/validation.R

Description

validate - asserts the following:

check - returns the following:

Usage

1
2
3

Arguments

outcomes

An object to check.

Details

The expected way to use this validation function is to supply it the $outcomes element of the result of a call to mold().

Value

validate_outcomes_are_binary() returns outcomes invisibly.

check_outcomes_are_binary() returns a named list of three components, ok, bad_cols, and num_levels.

Validation

hardhat provides validation functions at two levels.

See Also

Other validation functions: validate_column_names(), validate_no_formula_duplication(), validate_outcomes_are_factors(), validate_outcomes_are_numeric(), validate_outcomes_are_univariate(), validate_prediction_size(), validate_predictors_are_numeric()

Examples

1
2
3
4
5
6
7
8
# Not a binary factor. 0 levels
check_outcomes_are_binary(data.frame(x = 1))

# Not a binary factor. 1 level
check_outcomes_are_binary(data.frame(x = factor("A")))

# All good
check_outcomes_are_binary(data.frame(x = factor(c("A", "B"))))

DavisVaughan/hardhat documentation built on Oct. 5, 2021, 9:53 a.m.