if_missing: Replace NULL and NA values

Description Usage Arguments Value Examples

View source: R/functions.R

Description

Replace NULL and NA values

Usage

1
if_missing(x, y)

Arguments

x

an object, usually an atomic one

y

value to be returned if x is NULL, of length 0, or if its first element is NA

Value

y, if x is NULL, length 0, or if x[1] is NA; x otherwise.

Examples

1
2
3
4
if_missing(NULL, "n/a")
if_missing(NA, "n/a")
if_missing(c(), "n/a")
if_missing("something", "n/a")

alexanderbrenning/alexmisc documentation built on Jan. 7, 2022, 5:41 p.m.