list_methods {svMisc} | R Documentation |
List all methods associated with a generic function or a class, or all types associated with a method
Description
List all S3 and/or S4 methods for a generic function or for a
class. List all types for a method; types are variants for a given method
defined in a way it is easy to add other variants dynamically (on the
contrary to a usual type =
or which =
argument, like in plot.ts()
or
plot.lm()
, respectively.
Usage
list_methods(
f = character(),
class = NULL,
S3 = TRUE,
S4 = TRUE,
mixed = TRUE,
filter = getOption("svGUI.methods")
)
list_types(method, class = "default", strict = FALSE)
listMethods(
f = character(),
class = NULL,
S3 = TRUE,
S4 = TRUE,
mixed = TRUE,
filter = getOption("svGUI.methods")
)
listTypes(method, class = "default", strict = FALSE)
Arguments
f |
The name of the generic function (character string), used only when
|
class |
The name of a class. |
S3 |
If |
S4 |
If |
mixed |
If |
filter |
A list of methods to consider when listing class methods. Only
classes in this list that are defined for the class are returned. Store the
list of methods you want in the options |
method |
The method name. |
strict |
Do we list only types for the class ( |
Value
For list_methods()
, if mixed = TRUE
, a list with components:
-
S3
The S3 methods for the generic function or the class, orcharacter(0)
if none -
S4
The S4 methods for the generic function or the class, orcharacter(0)
if none.
Otherwise, a character vector with the requested methods.
For list_types()
, a vector with character strings with methods' type names.
Note
list_types()
is only useful for special generic functions with type
argument like view
, copy
or export
. These functions offer a mechanism
to easily add custom types, and the present function list them. For S3
objects a type is simply a function whose name is : method_type.class.
So, adding new types for method is very easy to implement.
See Also
Examples
# Generic functions
list_methods("t.test") # S3
list_methods("show", mixed = FALSE) # S4
list_methods("ls") # None, not a generic function!
# Classes
# Only the following methods are considered
getOption("gui.methods")
list_methods(class = "data.frame")
list_methods(class = "lm")
# List method types
list_types("view") # All default view types currently defined
list_types("view", "data.frame")
list_types("view", "data.frame", TRUE) # None, except if you defined custom views!