isS3method: Is 'method' the Name of an S3 Method?

Description Usage Arguments Value See Also Examples

Description

Checks if method is the name of a valid / registered S3 method. Alternatively, when f and class are specified, it is checked if f is the name of an S3 generic function and paste(f, class, sep=".") is a valid S3 method.

Usage

1
isS3method(method, f, class, envir = parent.frame())

Arguments

method

a character string, typically of the form "<fn>.<class>". If omitted, f and class have to be specified instead.

f

optional character string, typically specifying an S3 generic function. Used, when method is not specified.

class

optional character string, typically specifying an S3 class name. Used, when method is not specified.

envir

the environment in which the method and its generic are searched first, as in getS3method().

Value

logical TRUE or FALSE

See Also

methods, getS3method.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
isS3method("t")           # FALSE - it is an S3 generic
isS3method("t.default")   # TRUE
isS3method("t.ts")        # TRUE
isS3method("t.test")      # FALSE
isS3method("t.data.frame")# TRUE
isS3method("t.lm")        # FALSE - not existing
isS3method("t.foo.bar")   # FALSE - not existing

## S3 methods with "4 parts" in their name:
ff <- c("as.list", "as.matrix", "is.na", "row.names", "row.names<-")
for(m in ff) if(isS3method(m)) stop("wrongly declared an S3 method: ", m)
(m4 <- paste(ff, "data.frame", sep="."))
for(m in m4) if(!isS3method(m)) stop("not an S3 method: ", m)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.