| get_sig_text {Rdpack} | R Documentation |
Produce the textual form of the signatures of available methods for an S4 generic function.
Here we find all methods for show() defined in package
"methods" and print the first few of them:
fn <- utils::help("show-methods", package = "methods")
rdo <- utils:::.getHelpFile(fn)
head(get_sig_text(rdo))
##: [1] "signature(object = \"ANY\")"
##: [2] "signature(object = \"MethodDefinition\")"
##: [3] "signature(object = \"MethodDefinitionWithTrace\")"
##: [4] "signature(object = \"MethodSelectionReport\")"
##: [5] "signature(object = \"MethodWithNext\")"
##: [6] "signature(object = \"MethodWithNextWithTrace\")"
get_sig_text(rdo, package = NULL)
rdo |
an Rd object. |
package |
if of class "character", give only methods defined by
|
Signatures are found using function findMethodSignatures from
package "methods".
A character vector with one element for each method.
todo: It would be better to call promptMethods() to get the signatures but in version R-2.13.x I had trouble with argument ‘where’ (could not figure out how to use it to restrict to functions from a package; also, promptMethods() seemed to call the deprecated function getMethods()). Check how these things stand in current versions of R, there may be no problem any more (checked, in 2.14-0 it is the same).
Georgi N. Boshnakov
require("stats4") # to ensure the presence of S4 methods from
# at least one package other than "methods"
fn <- help("show-methods", package = "methods")
rdo <- utils:::.getHelpFile(fn)
# this will find all methods for "show" in currently loaded packages
get_sig_text(rdo)
# this will select only the ones from package "stats4"
get_sig_text(rdo, package = "stats4")
# this is also fine but need to choose
# the appropriate element of "fn" if length(fn) > 1
fn <- help("show-methods")
# this finds nothing
fn <- help("logLik-methods", package = "methods")
# this does
fn <- help("logLik-methods", package = "stats4")
rdo <- utils:::.getHelpFile(fn)
get_sig_text(rdo)
get_sig_text(rdo, package = "stats4")