h_default_if_empty: Getting the default value for an empty object

View source: R/helpers.R

h_default_if_emptyR Documentation

Getting the default value for an empty object

Description

[Stable]

A simple helper function that sets a default value for an empty or missing object, that is an object for which length() function returns 0L or it has length 1 and is.na() returns TRUE.

Usage

h_default_if_empty(x, default)

Arguments

x

(any)
an object to handle. It can be any object for which length() function is defined.

default

(any)
a default value for x object.

Examples

h_default_if_empty(character(0), default = "default label")
h_default_if_empty("custom label", default = "default label")
h_default_if_empty(NA, default = "default label")

Roche/crmPack documentation built on April 30, 2024, 3:19 p.m.