validate_no_formula_duplication: Ensure no duplicate terms appear in 'formula'

Description Usage Arguments Value Validation See Also Examples

View source: R/validation.R

Description

validate - asserts the following:

check - returns the following:

Usage

1
2
3

Arguments

formula

A formula to check.

original

A logical. Should the original names be checked, or should the names after processing be used? If FALSE, y ~ log(y) is allowed because the names are "y" and "log(y)", if TRUE, y ~ log(y) is not allowed because the original names are both "y".

Value

validate_no_formula_duplication() returns formula invisibly.

check_no_formula_duplication() returns a named list of two components, ok and duplicates.

Validation

hardhat provides validation functions at two levels.

See Also

Other validation functions: validate_column_names(), validate_outcomes_are_binary(), 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
 9
10
11
12
13
14
# All good
check_no_formula_duplication(y ~ x)

# Not good!
check_no_formula_duplication(y ~ y)

# This is generally okay
check_no_formula_duplication(y ~ log(y))

# But you can be more strict
check_no_formula_duplication(y ~ log(y), original = TRUE)

# This would throw an error
try(validate_no_formula_duplication(log(y) ~ log(y)))

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