assertions {tern}R Documentation

Additional assertions to use with checkmate

Description

Additional assertion functions which can be used together with the checkmate package.

Usage

assert_list_of_variables(x, .var.name = checkmate::vname(x), add = NULL)

assert_df_with_variables(
  df,
  variables,
  na_level = NULL,
  .var.name = checkmate::vname(df),
  add = NULL
)

assert_valid_factor(
  x,
  min.levels = 1,
  max.levels = NULL,
  null.ok = TRUE,
  any.missing = TRUE,
  n.levels = NULL,
  len = NULL,
  .var.name = checkmate::vname(x),
  add = NULL
)

assert_df_with_factors(
  df,
  variables,
  min.levels = 1,
  max.levels = NULL,
  any.missing = TRUE,
  na_level = NULL,
  .var.name = checkmate::vname(df),
  add = NULL
)

assert_proportion_value(x, include_boundaries = FALSE)

Arguments

x

(any)
object to test.

.var.name

[character(1)]
Name of the checked object to print in assertions. Defaults to the heuristic implemented in vname.

add

[AssertCollection]
Collection to store assertion messages. See AssertCollection.

df

(data.frame)
data set to test.

variables

(named list of character)
list of variables to test.

na_level

(string)
the string you have been using to represent NA or missing data. For NA values please consider using directly is.na() or similar approaches.

min.levels

[integer(1)]
Minimum number of factor levels. Default is NULL (no check).

max.levels

[integer(1)]
Maximum number of factor levels. Default is NULL (no check).

null.ok

[logical(1)]
If set to TRUE, x may also be NULL. In this case only a type check of x is performed, all additional checks are disabled.

any.missing

[logical(1)]
Are vectors with missing values allowed? Default is TRUE.

n.levels

[integer(1)]
Exact number of factor levels. Default is NULL (no check).

len

[integer(1)]
Exact expected length of x.

include_boundaries

(flag)
whether to include boundaries when testing for proportions.

Value

Nothing if assertion passes, otherwise prints the error message.

Functions


[Package tern version 0.9.5 Index]