is.missing: Detect missing arguments in link... arguments

Description Usage Arguments Value Note Author(s) See Also

Description

These are useful for writing functions that accept any number of arguments but some may be missing. For example, arrays in R can have any number of dimensions, indexed by the [ function, where a missing argument means to take all indexes on that dimension. However there is not a good way to replicate ['s behavior in base R; using list(...) to collect all positional arguments will throw errors on missing arguments. Instead, use x <- list_missing(...) and is.missing(x) to detect missing arguments.

For ... objects as made by dots, performs this check without forcing evaluation.

Usage

1
2
3
4
5

Arguments

...

for dots_missing, any number of arguments, each being checked for missingness, without being evaluated.

x

If given a list, compares each element with the missing value. Given a dots object, determines whether each argument is empty or missing.

Value

For dots_missing, a logical vector.

For list_missing, a named list of all evaluated arguments, where any missing arguments are set to missing_value().

For is.missing, a vector of boolean values.

Note

A frequently seen strategy is to use match.call(expand.dots=TRUE) and eval(..., parent.frame()) to screen for missing arguments while evaluating non-missing arguments. This is not recommended because match.call does not capture the environments of the arguments, leading to hygeine violations.

Author(s)

Peter Meilstrup

See Also

missing_value


crowding/vadr documentation built on May 14, 2019, 11:33 a.m.