- Notifications
You must be signed in to change notification settings - Fork14
Common generic methods
License
Unknown, MIT licenses found
Licenses found
r-lib/generics
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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.
To installgenerics from CRAN, use:
install.packages("generics")To install the development version, use:
# install.packages("pak")pak::pak("r-lib/generics")
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).
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
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors12
Uh oh!
There was an error while loading.Please reload this page.