Package: generics 0.1.3.9000
generics: Common S3 Generics not Provided by Base R Methods Related to Model Fitting
In order to reduce potential package dependencies and conflicts, generics provides a number of commonly used S3 generics.
Authors:
generics_0.1.3.9000.tar.gz
generics_0.1.3.9000.zip(r-4.5)generics_0.1.3.9000.zip(r-4.4)generics_0.1.3.9000.zip(r-4.3)
generics_0.1.3.9000.tgz(r-4.5-any)generics_0.1.3.9000.tgz(r-4.4-any)generics_0.1.3.9000.tgz(r-4.3-any)
generics_0.1.3.9000.tar.gz(r-4.5-noble)generics_0.1.3.9000.tar.gz(r-4.4-noble)
generics_0.1.3.9000.tgz(r-4.4-emscripten)generics_0.1.3.9000.tgz(r-4.3-emscripten)
generics.pdf |generics.html✨
generics/json (API)
NEWS
# Install 'generics' in R: |
install.packages('generics', repos = c('https://r-lib.r-universe.dev', 'https://cloud.r-project.org')) |
Bug tracker:https://github.com/r-lib/generics/issues
Pkgdown site:https://generics.r-lib.org
On CRAN:generics-0.1.3(2022-07-05)
Last updated 1 years agofrom:46fd716fe5. Checks:8 OK. Indexed: yes.
Target | Result | Latest binary |
---|---|---|
Doc / Vignettes | OK | Feb 02 2025 |
R-4.5-win | OK | Feb 19 2025 |
R-4.5-mac | OK | Feb 02 2025 |
R-4.5-linux | OK | Feb 02 2025 |
R-4.4-win | OK | Feb 02 2025 |
R-4.4-mac | OK | Feb 02 2025 |
R-4.3-win | OK | Feb 02 2025 |
R-4.3-mac | OK | Feb 02 2025 |
Exports:accuracyas.difftimeas.factoras.orderedaugmentcalculatecompilecomponentsequationestfunevaluateexplainexplorefitfit_xyforecastgenerateglancehypothesizeinterpolateintersectis.elementlearnmin_gridprunerank_resultsrefitrequired_pkgssetdiffsetequalspecifytidytraintunabletune_argsunionvar_impvarying_argsvisualize
Dependencies:
Citation
To cite package ‘generics’ in publications use:
Wickham H, Kuhn M, Vaughan D (2025). generics: Common S3 Generics not Provided by Base R Methods Related to Model Fitting. R package version 0.1.3.9000, , https://github.com/r-lib/generics.
Corresponding BibTeX entry:
@Manual{, title = {generics: Common S3 Generics not Provided by Base R Methods Related to Model Fitting}, author = {Hadley Wickham and Max Kuhn and Davis Vaughan}, year = {2025}, note = {R package version 0.1.3.9000, }, url = {https://github.com/r-lib/generics}, }
Readme and manuals
generics
generics
is designed to help package authors reduce dependencies by
providing a set of generic methods that can be imported. For example, if
a package author wanted to include a tidy
method for their object,
they would have to import the broom
package to do so. This would work
but would potentially increase the number of package dependencies
required to install and/or test the package.
Installation
To install generics
from CRAN, use:
install.packages("generics")
To install the development version, use:
# install.packages("pak")
# pak::pak("r-lib/generics")
install.packages("generics", repos = c('https://r-lib.r-universe.dev', 'https://cloud.r-project.org'))
Usage
generics
is a simple, lightweight package that contains S3 generics to
be 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, union
fit
#> function (object, ...)
#> {
#> UseMethod("fit")
#> }
#> <bytecode: 0x11c3908c0>
#> <environment: namespace:generics>
tidy
#> function (x, ...)
#> {
#> UseMethod("tidy")
#> }
#> <bytecode: 0x11c3fe540>
#> <environment: namespace:generics>
To use generics
with your package, we recommend that you import and
re-export the generic(s) of interest. For example, if you want to
provide a method for the S3 explain()
method, you’d using the
following roxygen2
code:
#' @importFrom generics explain
#' @export
generics::explain
As an example, the recipes
package defines a number of tidy()
S3 methods by importing this
package (whereas it previously depended on broom
).
Documentation
When searching for help on a method that is exported from generics
by
one or more packages, using ?method
will show entries for all exported
methods. If the version from generics
is selected, the Methods section
dynamically lists all specific methods exported by any loaded packages.