Skip to contents

[Experimental]

Check whether x is a (single) proportion.

Usage

check_proportion(x, null.ok = FALSE)

assert_proportion(
  x,
  null.ok = FALSE,
  .var.name = checkmate::vname(x),
  add = NULL
)

test_proportion(x, null.ok = FALSE)

expect_proportion(x, null.ok = FALSE, info = NULL, label = vname(x))

Arguments

x

an object to check.

null.ok

(flag)
whether x may also be NULL.

.var.name

(string)
name of the checked object to print in assertions; defaults to the heuristic implemented in checkmate::vname().

add

(AssertCollection or NULL)
collection to store assertion messages, see checkmate::AssertCollection.

info

(string)
extra information to be included in the message for the testthat reporter, see testthat::expect_that().

label

(string)
name of the checked object to print in messages. Defaults to the heuristic implemented in checkmate::vname().

Value

TRUE if successful, otherwise a string with the error message.

See also

assertions for more details.

Examples

check_proportion(0.25)
#> [1] TRUE