op-zero-length | R Documentation |
Infix function implementing provision of an alternative if an object has zero length.
x %L% y
x , y |
atomic vector arguments or other objects for which |
The infix function %L%
may be useful in implementing if (length(x)) x else y
and
was inspired by the null coalescing operator %||%
.
x
, or if length(x)
is zero, y
.
%||%
.
c4 <- letters[1:4]
c0 <- character(0)
n3 <- 1:3
n0 <- numeric(0)
c4 %L% n3
c0 %L% n3
n3 %L% c4
n0 %L% c4
rm(c4, c0, n3, n0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.