Skip to content

Commit fc0ff18

Browse files
committed
fix match.arg2
1 parent bf3132b commit fc0ff18

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

R/utils.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,10 @@ decode <- function(con, mode) {
242242
}
243243

244244
match.arg2 <- function(choice, choices) {
245-
arg <- deparse(substitute(choice))
246-
index <- pmatch(choice[1L], choices, nomatch = 0L)
247-
index || stop(sprintf("'%s' should be one of %s", arg, paste(choices, collapse = ", ")))
245+
identical(choice, choices) && return(1L)
246+
index <- pmatch(choice[1L], choices, nomatch = 0L, duplicates.ok = TRUE)
247+
index || stop(sprintf("'%s' should be one of %s",
248+
deparse(substitute(choice)), paste(choices, collapse = ", ")))
248249
index
249250
}
250251

0 commit comments

Comments
 (0)