Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

default

Retrieve a value or a default


Description

a %||% b returns a unless it is empty, in which case b is returned.

Usage

a %||% b

lhs %|% rhs

Arguments

a

the value to return if non-empty

b

default value

lhs

vector with potentially missing values, or NULL

rhs

vector with default values, same length as lhs unless that is NULL

Value

a %||% b returns a, unless it is NULL, empty, FALSE or ""; in which case b is returned.

lhs %|% rhs returns a vector of the same length as rhs with all missing values in lhs replaced by the corresponding values in rhs.


box

Write Reusable, Composable and Modular R Code

v1.0.2
MIT + file LICENSE
Authors
Konrad Rudolph [aut, cre] (<https://orcid.org/0000-0002-9866-7051>), Michael Schubert [ctb] (<https://orcid.org/0000-0002-6862-5221>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.