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 write extra documentation for the new function, an other .Rd file is created and competes with the original base R function (R asks you to choose which one you want when you run ?setdiff
).
Is there a clean way to do this?
?setMethod
? – Janaye