# Let's give an example
test_check = function(x, y, arg.check = TRUE){
set_check(arg.check)
check_arg(x, y, "numeric scalar")
x + y
}
# Works: argument checking on
test_check(1, 2)
# If mistake, nice error msg
try(test_check(1, "a"))
# Now argument checking turned off
test_check(1, 2, FALSE)
# But if mistake: "not nice" error message
try(test_check(1, "a", FALSE))
Run the code above in your browser using DataLab