Return the given object or a default value if the object is NA
defaultIfNA(x, default, count = FALSE)
x | vector possibly containing NA values |
---|---|
default | default value that is returned if |
count | if |
x
if x
is not NA and default
otherwise
defaultIfNA(NA, "default") # returns the default value#> [1] "default"defaultIfNA("actual", "default") # returns the "actual" value#> [1] "actual"