A flag indicating that the default value of an argument should be used.
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 thepoint_interval()
family of functions.
Examples
f = auto_partial(function(x, y = "b") {
c(x = x, y = y)
})
f("a")
#> x y
#> "a" "b"
# uses the default value of `y` ("b")
f("a", y = waiver())
#> x y
#> "a" "b"
# partially apply `f`
g = f(y = "c")
g
#> <partial_function>:
#> f(y = "c")
# uses the last partially-applied value of `y` ("c")
g("a", y = waiver())
#> x y
#> "a" "c"