| null_or | R Documentation |
Returns the left-hand side (a) if it is not NULL, otherwise returns
the right-hand side (b). This operator is useful for setting default
values in a concise manner.
a %||% b
a |
The primary object or value. |
b |
The default object or value to return if |
Null-coalescing operator
This implementation mirrors the behavior of %||% used in several
R ecosystems (e.g., rlang, purrr) but is defined here for
convenience within the TemporalForest package.
a if not NULL, otherwise b.
The %||% operator name is also used in packages such as rlang and purrr.
If you load those packages after TemporalForest, they may mask this operator.
To avoid ambiguity, call it explicitly using
TemporalForest::\%||%\“.
a <- NULL
b <- 5
a %||% b # Returns 5
x <- 10
y <- 20
x %||% y # Returns 10
# Safe usage when multiple packages define %||%
TemporalForest::`%||%`(NULL, "default")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.