Skip to contents

check arguments by custom function

Usage

check_arg(..., n = 2, fun = not.null)

Arguments

...

arguments

n

how many arguments should meet the custom conditions

fun

custom conditions defined by a function

Value

logical value

Examples

x <- 1
y <- 3
z <- NULL

func <- function(x = NULL, y = NULL, z = NULL) {
  if (check_arg(x, y, z, n = 2)) {
    print("As expected, two arguments is not NULL")
  }

  if (check_arg(x, y, z, n = 1, method = ~ .x < 2)) {
    print("As expected, one argument less than 2")
  }
}