Package: generics 0.1.3.9000

Hadley Wickham

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:Hadley Wickham [aut, cre], Max Kuhn [aut], Davis Vaughan [aut], Posit Software, PBC [cph, fnd]

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)

13.95 score 61 stars 9.7k packages 131 scripts 852k downloads 1 mentions 39 exports 0 dependencies

Last updated 1 years agofrom:46fd716fe5. Checks:8 OK. Indexed: yes.

TargetResultLatest binary
Doc / VignettesOKFeb 02 2025
R-4.5-winOKFeb 19 2025
R-4.5-macOKFeb 02 2025
R-4.5-linuxOKFeb 02 2025
R-4.4-winOKFeb 02 2025
R-4.4-macOKFeb 02 2025
R-4.3-winOKFeb 02 2025
R-4.3-macOKFeb 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.

Help Manual

Help pageTopics
Accuracy measures for a modelaccuracy
Augment data with information from an objectaugment
Calculate statistics.calculate
Factor coercionas.factor as.ordered coercion-factor
Time difference coercionas.difftime as.difftime.default coercion-time-difference
Configure an objectcompile
Extract componentscomponents
Model equationsequation
Extracting the estimating functions of a fitted model.estfun
Evaluate an object.evaluate
Explain details of an objectexplain
Create an interactive visualization appropriate to a particular object typeexplore
Estimate model parameters.fit
Estimate model parameters.fit_xy
Forecasting from an objectforecast
Generate values based on inputsgenerate
Glance at an objectglance
Construct hypotheses.hypothesize
Interpolate missing valuesinterpolate
Estimate model parameters.learn
Determine the minimum set of model fitsmin_grid
Prune or reduce an objectprune
Compute relative rankings of a collection of objectsrank_results
Refitting modelsrefit
Determine packages required by objectsrequired_pkgs
Set operationsintersect is.element setdiff setequal setops union
Specify variables or other quantities.specify
Turn an object into a tidy tibbletidy
Estimate model parameters.train
Declare tunable parameterstunable
Determine arguments tagged for tuningtune_args
Calculation of variable importancevar_imp
Find any arguments that are not fully specified.varying_args
Visualize a data set or object.visualize