setOldClass             package:methods             R Documentation

_S_p_e_c_i_f_y _N_a_m_e_s _f_o_r _O_l_d-_S_t_y_l_e _C_l_a_s_s_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     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'.

_U_s_a_g_e:

     setOldClass(Classes, where = 1)

_A_r_g_u_m_e_n_t_s:

 Classes: A character vector of names for old-style classes. 

   where: Where to store the class definitions.

_D_e_t_a_i_l_s:

     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 the list `.OldClassesList' for 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.

_S_e_e _A_l_s_o:

     `setClass', `setMethod'

_E_x_a_m_p_l_e_s:

     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")

