testargs: Assert a function argument is of correct type

testargsR Documentation

Assert a function argument is of correct type

Description

  • testarg_num() asserts that the argument is a numeric value. Also rejects NaNs and NAs by default.

  • testarg_prop() asserts that the argument value lies between 0 and 1.

  • testarg_pos() asserts that the argument is positive.

  • testarg_not_this() asserts that the argument is different from one or several forbidden values.

  • testarg_char() asserts that the argument is a character.

  • testarg_log() asserts that the argument is a logical.

  • testarg_length() asserts that the argument has the correct length.

  • test_comrad_comm() asserts the format of the supplied community is standard.

Usage

testarg_num(arg, allow_nan = FALSE, allow_na = FALSE)

testarg_int(arg)

testarg_pos(arg)

testarg_prop(arg)

testarg_not_this(arg, forbidden)

testarg_char(arg)

testarg_log(arg)

testarg_length(arg, correct_length)

test_comrad_comm(comm)

test_comrad_tbl(comrad_tbl)

Arguments

arg

value of the asserted argument.

allow_nan

logical, should NaNs pass the test?

allow_na

logical, should NAs pass the test?

forbidden

a vector containing forbidden values.

correct_length

numeric, the length the argument should have.

comm

a tibble with one row per individual in the community and three columns:

  • z contains (numeric) traits values

  • species contains species names (characters)

  • ancestral_species contains acnestral species names (characters)

comrad_tbl

a tibble containing the output of a comrad simulation, as produced by run_simulation().

Details

Currently testarg_not_this() cannot be tested properly.

Author(s)

Theo Pannetier


TheoPannetier/comrad documentation built on April 8, 2023, 8:06 a.m.