default_ops: A null coalescing operator.

Description Usage Arguments Details Value Examples

Description

If the LHS eveluates to NULL, a zero-length vector, or an empty string, return the RHS, otherwise return the LHS.

Usage

1
2
3
4
5
6
7
8
9
a %||% b

a %|% b

a %|na|% b

a %|NA|% b

a %|null|% b

Arguments

a

Some value.

b

Some default value.

Details

%|% is a vectorized version of %||%

%|na|% returns the RHS if the LHS evaluates to NA

%|NA|% is a vectorized version of %|na|%

%|null|% explicitly works only on NULL but not empty strings and vectors.

Value

a, if a is not NULL, not an empty vector, not an empty string, or not NA.

Examples

1
2
3
4
5
a1 <- "some value"
a2 <- ""
b <- "default value"
a1 %||% b
a2 %||% b

gschofl/gsmisc documentation built on May 17, 2019, 8:52 a.m.