Skip to content
Prev 15890 / 63461 Next

Overloading methods in R

Thanks Gabor! This answers a big part of my question. I am just curious why 
something like this doesn't work in S4:

-------------------------
setGeneric("foo", function(object, ...) standardGeneric("foo"))

foo.NULL <- function(object, ...) {
	args <- list(...)
	classes <- sapply(args, class)
	.Class <- paste(classes, collapse = ".")
}

foo.default <- function(object, ...) paste("wrong args!")

foo.numeric <- function(object, ...) 2 * ..1
foo.numeric.numeric <- function(object, ...) ..1 + ..2