This help topic is for R version 1.7.1. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/methods/html/setOldClass.html
setOldClass {methods}R Documentation

Specify Names for Old-Style Classes

Description

The Classes argument is an old-style class assignment. In particular, if there is more than one name, we expect old-style class inheritance. Calling setOldClass establishes similar inheritance for formal method dispatch, so that the class names can be used in a call to setMethod.

Usage

setOldClass(Classes, where = 1)

Arguments

Classes

A character vector of names for old-style classes.

where

Where to store the class definitions.

Details

Each of the names will be defined as a virtual class, extending the remaining classes in Classes, and the class oldClass, which is the “root” of all old-style classes. See Methods for the details of method dispatch and inheritance.

The list .OldClassesList contains the old-style classes that are defined by the methods package. Each element of the list is an old-style list, with multiple character strings if inheritance is included. Each element of the list was passed to setOldClass when creating the methods package; therefore, these classes can be used in setMethod calls, with the inheritance as implied by the list.

See Also

setClass, setMethod

Examples

setOldClass(c("mlm", "lm"))
setGeneric("dfResidual", function(model)standardGeneric("dfResidual"))
setMethod("dfResidual", "lm", function(model)model$df.residual)

## dfResidual will work on mlm objects as well as lm objects
myData <- data.frame(time = 1:10, y = (1:10)^.5)
myLm <- lm(cbind(y, y^3)  ~ time, myData)



rm(myData, myLm)
removeGeneric("dfResidual")
removeClass("mlm")
removeClass("lm")

[Package methods version 1.7.1 ]