Skip to contents

Return the given object or a default value if the object is NULL

Usage

defaultIfNULL(x, default, count = FALSE)

Arguments

x

R object to be checked for NULL

default

default value that is returned if x is NULL

count

if TRUE (the default is FALSE) the number of replaced values is returned in the attributes count

Value

x if x is not NULL and default otherwise

Examples

defaultIfNULL(NULL, "default") # returns the default value
#> [1] "default"
defaultIfNULL("actual", "default") # returns the "actual" value
#> [1] "actual"