Learn R Programming

BBmisc (version 1.13)

coalesce: Returns first non-missing, non-null argument.

Description

Returns first non-missing, non-null argument, otherwise NULL.

We have to perform some pretty weird tryCatch stuff internally, so you should better not pass complex function calls into the arguments that can throw exceptions, as these will be completely muffled, and return NULL in the end.

Usage

coalesce(...)

Value

[any].

Arguments

...

[any]
Arguments.

Examples

Run this code
f = function(x,y) {
  print(coalesce(NULL, x, y))
}
f(y = 3)

Run the code above in your browser using DataLab