waiver: A waived argument

waiverR Documentation

A waived argument

Description

A flag indicating that the default value of an argument should be used.

Usage

waiver()

Details

A waiver() is a flag passed to a function argument that indicates the function should use the default value of that argument. It is used in two cases:

  • ggplot2 functions use it to distinguish between "nothing" (NULL) and a default value calculated elsewhere (waiver()).

  • ggdist turns ggplot2's convention into a standardized method of argument-passing: any named argument with a default value in an automatically partially-applied function can be passed waiver() when calling the function. This will cause the default value (or the most recently partially-applied value) of that argument to be used instead.

    Note: due to historical limitations, waiver() cannot currently be used on arguments to the point_interval() family of functions.

See Also

auto_partial(), ggplot2::waiver()

Examples

f = auto_partial(function(x, y = "b") {
  c(x = x, y = y)
})

f("a")

# uses the default value of `y` ("b")
f("a", y = waiver())

# partially apply `f`
g = f(y = "c")
g

# uses the last partially-applied value of `y` ("c")
g("a", y = waiver())

mjskay/ggdist documentation built on Nov. 21, 2024, 10:46 a.m.