1% File src/library/utils/man/isS3method.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2016 R Core Team 4% Distributed under GPL 2 or later 5 6\name{isS3method} 7\alias{isS3method} 8\title{Is 'method' the Name of an S3 Method?} 9\description{ 10 Checks if \code{method} is the name of a valid / registered S3 11 method. Alternatively, when \code{f} and \code{class} are specified, 12 it is checked if \code{f} is the name of an S3 generic function and 13 \code{paste(f, class, sep=".")} is a valid S3 method. 14} 15\usage{ 16isS3method(method, f, class, envir = parent.frame()) 17} 18\arguments{ 19 \item{method}{a character string, typically of the form 20 \code{"<fn>.<class>"}. If omitted, \code{f} and \code{class} have 21 to be specified instead.} 22 \item{f}{optional character string, typically specifying an S3 generic 23 function. Used, when \code{method} is not specified.} 24 \item{class}{optional character string, typically specifying an S3 25 class name. Used, when \code{method} is not specified.} 26 \item{envir}{the \code{\link{environment}} in which the method and its 27 generic are searched first, as in \code{\link{getS3method}()}.} 28} 29%% \details{ 30%% } 31\value{ 32 \code{\link{logical}} \code{TRUE} or \code{FALSE} 33} 34\seealso{ 35 \code{\link{methods}}, \code{\link{getS3method}}. 36} 37\examples{ 38isS3method("t") # FALSE - it is an S3 generic 39isS3method("t.default") # TRUE 40isS3method("t.ts") # TRUE 41isS3method("t.test") # FALSE 42isS3method("t.data.frame")# TRUE 43isS3method("t.lm") # FALSE - not existing 44isS3method("t.foo.bar") # FALSE - not existing 45 46## S3 methods with "4 parts" in their name: 47ff <- c("as.list", "as.matrix", "is.na", "row.names", "row.names<-") 48for(m in ff) if(isS3method(m)) stop("wrongly declared an S3 method: ", m) 49(m4 <- paste(ff, "data.frame", sep=".")) 50for(m in m4) if(!isS3method(m)) stop("not an S3 method: ", m) 51\dontshow{ 52stopifnot( 53 !isS3method("t"), !isS3method("t.test"), !isS3method("qr.coef"), !isS3method("sort.list"), 54 isS3method("t.default"), isS3method("t.ts"), isS3method("t.data.frame"), 55 !isS3method("t.lm"), !isS3method("t.foo.bar")) 56} 57} 58\keyword{methods} 59