Open TimTaylor opened 2 weeks ago
assert_range <- function( x, ..., .arg = deparse(substitute(x)), .call = sys.call(-1L), .subclass = NULL ) { .assert_not_missing(x, ..., .arg = .arg, .call = .call, .subclass = .subclass) if (!is.numeric(x) || length(x) != 2L || anyNA(x)) { msg <- sprintf("`%s` must be a non-missing numeric vector of length 2.", .arg) .stop(msg, ..., .call = .call, .subclass = .subclass) } if (x[2L] < x[1L]) { msg <- sprintf("`%s` must be non-decreasing.", .arg) .stop(msg, ..., .call = .call, .subclass = .subclass) } }
assert_scalar_percentage <- function( x, ..., .arg = deparse(substitute(x)), .call = sys.call(-1L), .subclass = NULL ) { .assert_not_missing(x, ..., .arg = .arg, .call = .call, .subclass = .subclass) if (!(is.numeric(x) && length(x) == 1L) || is.na(x) || x < 0 || x > 1) { msg <- sprintf("`%s` must be a non-missing, scalar numeric vector between 0 and 1.", .arg) .stop(msg, ..., .call = .call, .subclass = .subclass) } }
maybe but I'm not sure??