Open
Description
- present base R features to play with
...
:...names()
,...elt(n)
,...length()
, etc. - when to use
...
?- pass arguments to a function chosen by the user (e.g.
apply()
) - S3 methods
- forward compatibility
- pass arguments to a function chosen by the user (e.g.
- base R function
chkDots()
- explain how to pass a default value to an argument in
...
f <- function(x, ...) {
xargs <- list(...)
if (is.null(xargs$na.rm))
xargs$na.rm <- TRUE
xargs$x <- x
do.call(quantile, xargs)
}
f(1:10)
#> 0% 25% 50% 75% 100%
#> 1.00 3.25 5.50 7.75 10.00
f(c(1:10, NA))
#> 0% 25% 50% 75% 100%
#> 1.00 3.25 5.50 7.75 10.00
f(c(1:10, NA), na.rm = FALSE)
#> Error in quantile.default(na.rm = FALSE, x = c(1L, 2L, 3L, 4L, 5L, 6L, : missing values and NaN's not allowed if 'na.rm' is FALSE
Created on 2022-03-11 by the reprex package (v2.0.1.9000)
- explanation of the differences between the various approaches presented in this tweet? evaluated vs non-evaluated
- https://ellipsis.r-lib.org/
Bonus: Options for clickbait title
"Everything you've always wanted to know about ..."