use_default: Apply a default value whenever a variable is not well-formed
Description
This function provides a functional approach for a
specific use case of conditional expressions: that of
applying default values when a variable is not
well-formed. In this context, well-formedness is
considered to be any scalar value that is not NA. By
encapsulating this behavior in a function, referential
transparency is preserved.
Arguments
x
a scalar variable
default
the value to replace empty, NULL, or NA
Value
A well-formed value, either the original value or the
default if x is not well-formed.