1% File src/library/utils/man/getS3method.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2015 R Core Team 4% Distributed under GPL 2 or later 5 6\name{getS3method} 7\alias{getS3method} 8\title{Get an S3 Method} 9\description{ 10 Get a method for an S3 generic, possibly from a namespace or the 11 generic's registry. 12} 13\usage{ 14getS3method(f, class, optional = FALSE, envir = parent.frame()) 15} 16\arguments{ 17 \item{f}{a character string giving the name of the generic.} 18 \item{class}{a character string giving the name of the class.} 19 \item{optional}{logical: should failure to find the generic or a 20 method be allowed?} 21 \item{envir}{the \code{\link{environment}} in which the method and its 22 generic are searched first.} 23} 24\details{ 25 S3 methods may be hidden in namespaces, and will not 26 then be found by \code{\link{get}}: this function can retrieve 27 such functions, primarily for debugging purposes. 28 29 Further, S3 methods can be registered on the generic when a namespace 30 is loaded, and the registered method will be used if none is visible 31 (using namespace scoping rules). 32 33 It is possible that which S3 method will be used may depend on where 34 the generic \code{f} is called from: \code{getS3method} returns the 35 method found if \code{f} were called from the same environment. 36} 37\value{ 38 The function found, or \code{NULL} if no function is found and 39 \code{optional = TRUE}. 40} 41\seealso{ 42 \code{\link{methods}}, \code{\link{get}}, \code{\link{getAnywhere}} 43} 44\examples{ 45require(stats) 46exists("predict.ppr") # false 47getS3method("predict", "ppr") 48} 49\keyword{data} 50\keyword{methods} 51