Return the given object or a default value if the object is NULL
defaultIfNULL(x, default, count = FALSE)
x | R object to be checked for NULL |
---|---|
default | default value that is returned if |
count | if |
x
if x
is not NULL and default
otherwise
defaultIfNULL(NULL, "default") # returns the default value#> [1] "default"defaultIfNULL("actual", "default") # returns the "actual" value#> [1] "actual"