removeMethods
Remove all the Methods for a Function
Description
Remove all the registered methods for a function.
Usage
removeMethods(f, where = topenv(parent.frame()), all = missing(where))
removeMethod(f, signature = character(), where = topenv(parent.frame()))
removeGeneric(f, where = topenv(parent.frame()))
Arguments
f |
a character string. The name of the generic function.
|
where |
the attached package from which to remove the methods.
|
all |
a logical value.
This argument is not supported in TIBCO Enterprise Runtime for R.
|
signature |
a character string. The signature of the method to remove.
If signature is not supplied, remove the default method.
|
Value
returns TRUE if methods are removed successfully; otherwise it returns FALSE.
Side effects
removeMethod | | Removes a single method from the generic function. |
removeMethods | | Removes the generic function named f and all
its methods from the package where.
If the variable f in the environment where contains a
generic function, all of the generic function's methods are removed.
If f has a default method, then the variable f is set to
an ordinary function derived from the default method of the generic. |
removeGeneric("f") | | The same as removeMethods, except
that it always removes the variable f, rather than setting it to
an ordinary function.
|
See Also
Examples
# remove foo and reset it to the default method
foo <- function(x) "original non-generic foo"
setGeneric("foo", function(x) standardGeneric("foo"))
setMethod("foo", "integer", function(x) "integer method for foo")
setMethod("foo", "character", function(x) "character method for foo")
setMethod("foo", "numeric", function(x) "numeric method for foo")
foo(as.integer(1))
# [1] "integer method for foo"
foo(as.numeric(1))
# [1] "numeric method for foo"
removeMethod("foo", "integer")
# [1] TRUE
foo(as.integer(1))
# [1] "numeric method for foo"
removeMethods("foo")
foo(as.integer(1))
# [1] "original non-generic foo"
foo <- function(x) "original non-generic foo"
setGeneric("foo", function(x) standardGeneric("foo"))
setMethod("foo", "integer", function(x) "integer method for foo")
removeGeneric("foo")
# [1] TRUE
exists("foo", inherits=FALSE)
# [1] FALSE