Tools for Working with ...

The ellipsis is a powerful tool for extending functions. Unfortunately this power comes at a cost: misspelled arguments will be silently ignored. The ellipsis package provides a collection of functions to catch problems and alert the user.


lifecycle Travis buildstatus Coveragestatus

Adding ... to an S3 generic allows methods to take additional arguments, but it comes with a big downside: any misspelled or extraneous arguments will be silently ignored. This package explores an approach to making ... safer, by supply a function that a generic can use to warn if any elements of ... were not evaluated.

In the long run, this code is likely to live elsewhere (maybe R-core might be interested in making it part of base R). This repository tracks the current state of the experiment.

Thanks to Jenny Bryan for the idea, and Lionel Henry for the heart of the implementation.

Installation

devtools::install_github("hadley/ellipsis")

Example

safe_median() works like median() but warns if any elements of ... are never evaluated

library(ellipsis)
x <- c(1:10, NA)
 
safe_median(x)
#> [1] 5.5
safe_median(x, TRUE)
#> Warning: Some components of ... were not used: ..1
#> [1] 5.5
safe_median(x, na.rm = TRUE)
#> [1] 5.5
safe_median(x, na.mr = TRUE)
#> Warning: Some components of ... were not used: na.mr
#> [1] 5.5

News

ellipsis 0.1.0

  • New check_dots_unnamed() that checks that all components of ... are unnamed (#7).

  • Fix a bug that caused check_dots_used() to emit many false positives (#8)

ellipsis 0.0.2

  • Fix a PROTECTion error

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ellipsis")

0.3.0 by Hadley Wickham, 2 months ago


https://ellipsis.r-lib.org, https://github.com/r-lib/ellipsis


Report a bug at https://github.com/r-lib/ellipsis/issues


Browse source code at https://github.com/cran/ellipsis


Authors: Hadley Wickham [aut, cre] , RStudio [cph]


Documentation:   PDF Manual  


GPL-3 license


Imports rlang

Suggests covr, testthat


Imported by dabestr, devtools, distributions3, forcats, learnr, sparklyr, statsExpressions, testthat, tidyr, vctrs.


See at CRAN