Check if x is null. If so, return defaultValue, otherwise run function on x and return the result. If a value x is encountered that is NULL, and nullable is set to FALSE, execution will be stopped and an error message will be printed.

valueOrDefault(x, FUN = identity, nullable = TRUE, defaultValue = "null", ...)

Arguments

x

the argument to create a value for.

FUN

the function to apply to x, if x is not NULL.

nullable

if TRUE, NULL is a valid value, otherwise, an error will be raised.

defaultValue

the value to return, if x is NULL.

...

arguments that will be passed on to FUN.