method_from_call: Given a function class, find correspoding S4 method

Description Usage Arguments Examples

View source: R/method-from-call.r

Description

Given a function class, find correspoding S4 method

Usage

1

Arguments

call

unquoted function call

env

environment in which to look for function definition

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(stats4)

# From example(mle)
y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)
nLL <- function(lambda) -sum(dpois(y, lambda, log = TRUE))
fit <- mle(nLL, start = list(lambda = 5), nobs = length(y))

method_from_call(summary(fit))
method_from_call(coef(fit))
method_from_call(length(fit))

Example output

Method Definition:

function (object, ...) 
{
    cmat <- cbind(Estimate = object@coef, `Std. Error` = sqrt(diag(object@vcov)))
    m2logL <- 2 * object@min
    new("summary.mle", call = object@call, coef = cmat, m2logL = m2logL)
}
<bytecode: 0x38b1fc8>
<environment: namespace:stats4>

Signatures:
        object
target  "mle" 
defined "mle" 
Method Definition:

function (object, ...) 
{
    .local <- function (object) 
    object@fullcoef
    .local(object, ...)
}
<bytecode: 0x38e3128>
<environment: namespace:stats4>

Signatures:
        object
target  "mle" 
defined "mle" 
function (x)  .Primitive("length")

pryr documentation built on May 2, 2019, 9:58 a.m.