NVL {statnet.common} | R Documentation |
NULL
.
This function is inspired by SQL function NVL
, and simply returns
the first argument that is not NULL
, or NULL
if all arguments are NULL.
NVL(...)
... |
Expressions to be tested. |
Note that an earlier version of this function took only two arguments:
EXPR
, that was tested and returned if not NULL
and
NULLV
, which was returned if EXPR
was
NULL
. The new version produces identical output for the same
(two-argument) input, but tests any number of expressions
sequentially.
The first argument that is not NULL
, or NULL
if all
are.
is.null, if
a <- NULL print(a) # NULL print(NVL(a,0)) # 0 b <- 1 print(b) # 1 print(NVL(b,0)) # 1 # Also, print(NVL(NULL,1,0)) # 1 print(NVL(NULL,0,1)) # 0 print(NVL(NULL,NULL,0)) # 0 print(NVL(NULL,NULL,NULL)) # NULL