Methods and classes for object-oriented programming in R with or without references. Large effort has been made on making definition of methods as simple as possible with a minimum of maintenance for package developers. The package has been developed since 2001 and is now considered very stable. This is a cross-platform package implemented in pure R that defines standard S3 classes without any tricks.
Please note that the Rdoc syntax/grammar used to convert Rdoc comments in code into Rd files is not strictly defined and is modified by the need of the author. Ideally, there will be a well defined Rdoc language one day.
To install this package do
install.packages("R.oo")
This package requires a standard R installation and the R.methodsS3 package.
To get started,It is very useful to understand that:
The setMethodS3
() function, which is
defined in the R.methodsS3 package (used to be part of
R.oo), is nothing but a conveniency wrapper for setting
up S3 methods, and automatically create an S3 generic
function, if missing. For more information, see the help of
R.methodsS3.
The Object
class is a top-level "root" class
that provides support for reference variables.
Any class inheriting from this class supports
reference variables.
The Object
class is basically a wrapper around an
environment
, which some additional accessors etc. It is the
environment data type that provides the "emulation" of
reference variables - the Object class structure makes
it easier to extends this class and adds some level of coding
protection. The Object class features is not intended for
referencing individual elements of basic R data types,
but rather for the whole variable of such.
For instance, you can reassign a whole matrix X
part of
the object this way, but you cannot reassign X[1,1]
without creating a completely new copy.
For a detailed introduction to the package see [1] (part of the package distribution).
Whenever using this package, please cite [1] as
Bengtsson, H. The R.oo package - Object-Oriented Programming with References Using Standard R Code, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), ISSN 1609-395X, Hornik, K.; Leisch, F. & Zeileis, A. (ed.), 2003
The releases of this package is licensed under LGPL version 2.1 or newer.
[1] H. Bengtsson, The R.oo package - Object-Oriented Programming with References Using Standard R Code, In Kurt Hornik, Friedrich Leisch and Achim Zeileis, editors, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), March 20-22, Vienna, Austria. https://www.r-project.org/conferences/DSC-2003/Proceedings/
People interested in R.oo may also be interested in packages proto and mutatr.