【描述】
List all available methods for a S3 and S4 generic function, or all methods for an S3 or S4 class.
关于S3和S4的介绍见https://www.jianshu.com/p/1caf31c2289d
【用法】
methods(generic.function, class)
.S3methods(generic.function, class, envir=parent.frame())
S3 method for class 'MethodsFunction'
format(x, byclass = attr(x, "byclass"), ...)
S3 method for class 'MethodsFunction'
print(x, byclass = attr(x, "byclass"), ...)
【参数】
generic.function
a generic function, or a character string naming a generic function.
class
a symbol or character string naming a class: only used if generic.function is not supplied.
envir
the environment in which to look for the definition of the generic function, when the generic function is passed as a character string.
x
typically the result of methods(..), an R object of S3 class "MethodsFunction", see ‘Value’ below.
byclass
an optional logical allowing to override the "byclass" attribute determining how the result is printed, see ‘Details’.
...
potentially further arguments passed to and from methods; unused currently.
【代码】
> methods(is)
[1] is.array is.atomic is.call is.character
[5] is.complex is.data.frame is.double is.element
[9] is.empty.model is.environment is.expression is.factor
[13] is.finite is.function is.infinite is.integer
[17] is.language is.leaf is.list is.loaded
[21] is.logical is.matrix is.mts is.na
[25] is.na.data.frame is.na.numeric_version is.na.POSIXlt is.na<-
[29] is.na<-.default is.na<-.factor is.na<-.numeric_version is.name
[33] is.nan is.null is.numeric is.numeric.Date
[37] is.numeric.difftime is.numeric.POSIXt is.numeric_version is.object
[41] is.ordered is.package_version is.pairlist is.primitive
[45] is.qr is.R is.raster is.raw
[49] is.recursive is.relistable is.single is.stepfun
[53] is.symbol is.table is.ts is.tskernel
[57] is.unsorted is.vector
see '?methods' for accessing help and source code
Warning message:
In .S3methods(generic.function, class, envir) :
function 'is' appears not to be S3 generic; found functions that look like S3 methods