Skip to contents

Checks whether variables always fall within a given range.

Usage

do_check(
  df,
  vars,
  check,
  label_check,
  template_ok = "all variables are {label_check}",
  template_fail = "{var} is not {label_check}"
)

Arguments

df

Data

vars

Character vector of variables to check

min

Minimum allowed value (default: 0)

max

Maximum allowed value (default: 1)

Value

List containing the results of the check (checks), and a tibble of status and message for each test (messages).

Details

Note that both the minimum and maximum are _inclusive_, that is, the range is given as [min, max]. For _exclusive_ checks, e.g. (0,1], or greater than 0, lesser than or equal to 1, the user will have to manually give a minimum value with a certain error applied (e.g., 1e-6).

The list of messages in the result contains a single line if the test passed, or if a test failed for one or more variables, a line for each failure.

Examples

data(df_pa)
check_range(df_pa, c("u_pfs", "p_pfspd"))
#> Error in check_range(df_pa, c("u_pfs", "p_pfspd")): object 'n_out' not found