Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

is_s3_generic

Determine if a function is an S3 generic or S3 method.


Description

is_s3_generic compares name checks for both internal and regular generics.

is_s3_method builds names of all possible generics for that function and then checks if any of them actually is a generic.

Usage

is_s3_generic(fname, env = parent.frame())

is_s3_method(name, env = parent.frame())

Arguments

env

environment to search in.

name

name of function as a string. Need name of function because it's impossible to determine whether or not a function is a S3 method based only on its contents.

Examples

is_s3_generic("mean")
is_s3_generic("sum")
is_s3_generic("[[")
is_s3_generic("unlist")
is_s3_generic("runif")

is_s3_method("t.data.frame")
is_s3_method("t.test") # Just tricking!
is_s3_method("as.data.frame")
is_s3_method("mean.Date")

pryr

Tools for Computing on the Language

v0.1.4
GPL-2
Authors
Hadley Wickham [aut, cre], R Core team [ctb] (Some code extracted from base R)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.