NVL {statnet.common} | R Documentation |
NULL
objects.Convenience functions for handling NULL
objects.
NVL(...) NVL(x) <- value
... |
Expressions to be tested. |
x |
an object to be overwritten if |
value |
new value for |
NVL
: Inspired by SQL function NVL
, NVL(...)
returns the first
argument that is not NULL
, or NULL
if all arguments
are NULL
.
NVL<-
: Assigning to NVL
overwrites its first argument if that argument
is NULL
. Note that it will always return the right-hand-side
of the assignment (value
), regardless of what x
is.
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 NVL(a) <- 2 a # 2 NVL(b) <- 2 b # still 1