util_is_numeric_in: Create a predicate function to check for certain numeric...

View source: R/util_is_numeric_in.R

util_is_numeric_inR Documentation

Create a predicate function to check for certain numeric properties

Description

useful, e.g., for util_expect_data_frame and util_expect_scalar. The generated function returns on TRUE or FALSE, even if called with a vector.

Usage

util_is_numeric_in(
  min = -Inf,
  max = +Inf,
  whole_num = FALSE,
  finite = FALSE,
  set = NULL
)

Arguments

min

if given, minimum for numeric values

max

if given, maximum for numeric values

whole_num

if TRUE, expect a whole number

finite

Are Inf and -Inf invalid values? (FALSE by default)

set

if given, a set, the value must be in (see util_match_arg)

Value

a function that checks an x for the properties.

See Also

Other robustness_functions: util_as_valid_missing_codes(), util_check_one_unique_value(), util_correct_variable_use(), util_empty(), util_ensure_character(), util_ensure_in(), util_ensure_suggested(), util_expect_scalar(), util_fix_rstudio_bugs(), util_is_integer(), util_is_valid_missing_codes(), util_match_arg(), util_observations_in_subgroups(), util_only_NAs(), util_stop_if_not(), util_warn_unordered()

Examples

## Not run: 
util_is_numeric_in(min = 0)(42)
util_is_numeric_in(min = 43)(42)
util_is_numeric_in(max = 3)(42)
util_is_numeric_in(whole_num = TRUE)(42)
util_is_numeric_in(whole_num = TRUE)(42.1)
util_is_numeric_in(set = c(1, 3, 5))(1)
util_is_numeric_in(set = c(1, 3, 5))(2)

## End(Not run)


dataquieR documentation built on May 29, 2024, 7:18 a.m.