Encapsulated Classes with Reference Semantics
Creates classes with reference semantics, similar to R's built-in
reference classes. Compared to reference classes, R6 classes are simpler
and lighter-weight, and they are not built on S4 classes so they do not
require the methods package. These classes allow public and private
members, and they support inheritance, even when the classes are defined in
R6: Encapsulated object-oriented programming for R
R6 is an implemention of encapsulated object-oriented programming for R, and is a simpler, faster, lighter-weight alternative to R's built-in reference classes. This style of programming is also sometimes referred to as classical object-oriented programming.
Some features of R6:
- R6 objects have reference semantics.
- R6 cleanly supports inheritance across packages.
- R6 classes have public and private members.
In contrast to R's reference classes, R6 is not built on the S4 class system, so it does not require the methods package. Unlike reference classes, R6 classes can be cleanly inherited across different packages.
See the Introduction article for usage examples.
To install R6 from CRAN:
To install the development version (requires the devtools package):
devtools::install_github('r-lib/R6', build_vignettes = FALSE)
- Introduction to R6
- Debugging methods in R6 objects
- Performance tests - Speed and memory comparisons of R6 classes and reference classes.
- Portable R6 classes - Inheritance across different packages.
Why the name R6? When R's reference classes were introduced, some users, following the names of R's existing class systems S3 and S4, called the new class system R5 in jest. Although reference classes are not actually called R5, the name of this package and its classes takes inspiration from that name.
The name R5 was also a code-name used for a different object system started by Simon Urbanek, meant to solve some issues with S4 relating to syntax and performance. However, the R5 branch was shelved after a little development, and it was never released.
Functions in R6
|as.list.R6||Create a list from an R6 object|
|is.R6||Is an object an R6 Class Generator or Object?|
|R6Class||Create an R6 reference object generator|
Last month downloads
|License||MIT + file LICENSE|
|Packaged||2019-02-14 18:34:54 UTC; winston|
|Date/Publication||2019-02-14 19:42:14 UTC|
Include our badge in your README