checkVariables: A error message generator, for checking classes of variables...

Description Usage Arguments Value Examples

View source: R/check_mate.r

Description

A error message generator, for checking classes of variables used in functions.

Usage

1
checkVariables(obj, expect_class, vari)

Arguments

obj

Variable object

expect_class

A string value of the expected class type

vari

A string value of the function variable name

Value

Null if no error occured, otherwise returns a custom error message.

Examples

1
2
3
4
5
6
7
8
9
# Will produce an error
a <- function(x){
  if (!is.null(err <- checkVariables(obj = x, req_class = "numerical", vari = "x"))) stop(err)
  return(x + 10)
}
# Will produce a costum error
a("one")
# Will execute the entire function
a(1)

KasperThystrup/circulaR documentation built on March 14, 2021, 12:44 p.m.