Skip to contents

Lightweight helper to extract a single named argument from a list (typically list(...)). If the argument is not present, a default value is returned.

Usage

getDotsArg(dots, name, default = NULL)

Arguments

dots

named list (usually list(...)).

name

character string, argument name.

default

default value if argument not present.

Value

the value of the argument or default.

See also

For extracting several arguments at once use extractArgs().

Other pkg.args: callIf(), extractArgs(), mergeArgs(), recycle()

Examples

f <- function(...) {
  dots <- list(...)
  getDotsArg(dots, "col", default = "black")
}

f(col = "red", lwd = 2)
#> [1] "red"
f(lwd = 2)
#> [1] "black"