Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Common generic methods

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

r-lib/generics

Repository files navigation

R-CMD-checkCodecov test coverage

generics is designed to help package authors reduce dependencies byproviding a set of generic methods that can be imported. For example, ifa package author wanted to include atidy method for their object,they would have to import thebroom package to do so. This would workbut would potentially increase the number of package dependenciesrequired to install and/or test the package.

Installation

To installgenerics from CRAN, use:

install.packages("generics")

To install the development version, use:

# install.packages("pak")pak::pak("r-lib/generics")

Usage

generics is a simple, lightweight package that contains S3 generics tobe used by other packages. Some examples are:

library(generics)#>#> Attaching package: 'generics'#> The following objects are masked from 'package:base':#>#>     as.difftime, as.factor, as.ordered, intersect, is.element, setdiff,#>     setequal, unionfit#> function(object, ...) {#>   UseMethod("fit")#> }#> <bytecode: 0x107df2b38>#> <environment: namespace:generics>tidy#> function(x, ...) {#>   UseMethod("tidy")#> }#> <bytecode: 0x107e583a8>#> <environment: namespace:generics>

To usegenerics with your package, we recommend that you import andre-export the generic(s) of interest. For example, if you want toprovide a method for the S3explain() method, you’d using thefollowingroxygen2 code:

#' @importFrom generics explain#' @exportgenerics::explain

As an example, therecipespackage defines a number oftidy() S3 methods by importing thispackage (whereas it previously depended onbroom).

Documentation

When searching for help on a method that is exported fromgenerics byone or more packages, using?method will show entries for all exportedmethods. If the version fromgenerics is selected, the Methods sectiondynamically lists all specific methods exported by any loaded packages.

About

Common generic methods

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Contributors12

Languages


[8]ページ先頭

©2009-2025 Movatter.jp