This function allows to disable, or re-enable, all calls to check_arg within any function. Useful only when running (very) large loops (>100K iter.) over small functions that use dreamerr's check_arg.

setDreamerr_check(check = TRUE)

Arguments

check

Strict logical: either TRUE of FALSE. Default is TRUE.

Author

Laurent Berge

Examples


# Let's create a small function that returns the argument
#  if it is a single character string, and throws an error
#  otherwise:

test = function(x){
  check_arg(x, "scalar character")
  x
}

# works:
test("hey")
#> [1] "hey"
# error:
try(test(55))
#> Error : in test(55):
#>  Argument `x` must be a character scalar.
#> PROBLEM: it is not of type character (instead it is of type 'numeric').

# Now we disable argument checking
setDreamerr_check(FALSE)
# works (although it shouldn't!):
test(55)
#> [1] 55

# re-setting argument checking on:
setDreamerr_check(TRUE)