Skip to content

Commit

Permalink
Use ellipsis to check for unmatched ...
Browse files Browse the repository at this point in the history
Fixes #174
  • Loading branch information
hadley committed Feb 14, 2019
1 parent 3f789ee commit 74830eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Expand Up @@ -20,6 +20,7 @@ BugReports: https://github.com/tidyverse/forcats/issues
Depends:
R (>= 3.1)
Imports:
ellipsis,
magrittr,
rlang,
tibble
Expand Down
1 change: 1 addition & 0 deletions R/as_factor.R
Expand Up @@ -14,6 +14,7 @@
#' as_factor(x)
#' as.factor(x)
as_factor <- function(x, ...) {
ellipsis::check_dots_used()
UseMethod("as_factor")
}

Expand Down
2 changes: 2 additions & 0 deletions R/reorder.R
Expand Up @@ -40,6 +40,7 @@
fct_reorder <- function(.f, .x, .fun = median, ..., .desc = FALSE) {
f <- check_factor(.f)
stopifnot(length(f) == length(.x))
ellipsis::check_dots_used()

summary <- tapply(.x, .f, .fun, ...)
if (!is.numeric(summary)) {
Expand All @@ -54,6 +55,7 @@ fct_reorder <- function(.f, .x, .fun = median, ..., .desc = FALSE) {
fct_reorder2 <- function(.f, .x, .y, .fun = last2, ..., .desc = TRUE) {
f <- check_factor(.f)
stopifnot(length(f) == length(.x), length(.x) == length(.y))
ellipsis::check_dots_used()

summary <- tapply(seq_along(.x), f, function(i) .fun(.x[i], .y[i], ...))
if (!is.numeric(summary)) {
Expand Down

1 comment on commit 74830eb

@jthomasmock
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your solution makes much more sense, this is much more general - catching all sorts of ellipsis "issues". Cool!

Please sign in to comment.