Skip to contents

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

Usage

defaultIfNA(x, default, count = FALSE)

Arguments

x

vector possibly containing NA values

default

default value that is returned if x is NA

count

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

Value

x if x is not NA and default otherwise

Examples

defaultIfNA(NA, "default") # returns the default value
#> [1] "default"
defaultIfNA("actual", "default") # returns the "actual" value
#> [1] "actual"