⚠️There's a newer version (0.3.2) of this package. Take me there.

ellipsis

Adding ... to an S3 generic allows methods to take additional arguments, but it comes with a big downside: any mispelled 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

Copy Link

Version

Down Chevron

Install

install.packages('ellipsis')

Monthly Downloads

517,888

Version

0.0.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 31st, 2018

Functions in ellipsis (0.0.1)