Turning an R S3 ordinary function into a generic
问题 FYI, looks like this question already has a LISP equivalent. Recently I wanted to create a dataframe extension to the R base function setdiff and thought a generic would be nice. The following works but is clunky: #' @export setdiff.default setdiff.default <- setdiff #' @export setdiff <- function(x, ...) { UseMethod("setdiff") } #' @export setdiff.data.frame <- function(A, B) { A[!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)], ] } When you load the package, the base function is masked. If I