[R-pkg-devel] S3 dispatch for select()
Kirill Müller
kirill.mueller at ivt.baug.ethz.ch
Wed May 24 09:34:15 CEST 2017
Hi
When a package defines a select() generic, objects of type list seem to
be forcibly dispatched to utils::select.list(). This is not the case
when the generic is defined in a regular R script. I could define a
select__() generic and forward all select() calls to select__() first,
but I wonder if there's a better way. Thanks.
Examples below, the first needs the *select* package [1].
Best regards
Kirill
[1] https://github.com/krlmlr/select
# 1. From package:
library(select)
select(letters)
#> [1] "select.default"
select(1:3)
#> [1] "select.default"
select(list(1:3))
#> Error in select.list(list(1:3)): select.list() cannot be used
non-interactively
# 2. From script
select <- function(x, ...) UseMethod("select")
select.default <- function(x, ...) "select.default"
select.list <- function(x, ...) "select.list"
select(letters)
#> [1] "select.default"
select(1:3)
#> [1] "select.default"
select(list(1:3))
#> [1] "select.list"
More information about the R-package-devel
mailing list