nonStructure-class          package:methods          R Documentation

_A _n_o_n-_s_t_r_u_c_t_u_r_e _S_4 _C_l_a_s_s _f_o_r _b_a_s_i_c _t_y_p_e_s

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

     S4 classes that are defined to extend one of the basic vector
     classes should contain the class 'structure' if they behave like
     structures; that is, if they should retain their class behavior
     under math functions or operators, so long as their length is
     unchanged. On the other hand, if their class depends on the values
     in the object, not just its structure, then they should lose that
     class under any such transformations.  In the latter case, they
     should be defined to contain 'nonStructure'.

     If neither of these strategies applies, the class likely needs
     some methods of its own for '\linkk{Ops}', 'Math', and/or other
     generic functions. What is not usually a good idea is to allow
     such computations to drop down to the default, base code.  This is
     inconsistent with most definitions of such classes.

_M_e_t_h_o_d_s:

     Methods are defined for operators and math functions (groups
     '\linkk{Ops}', 'Math' and  'Math2'.  In all cases the result is an
     ordinary vector of the appropriate type.

_R_e_f_e_r_e_n_c_e_s:

     Chambers, John M. (2008) _Software for Data Analysis: Programming
     with R_ Springer.

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

     'structure'

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

     setClass("NumericNotStructure", contains = c("numeric","nonStructure"))
     xx <- new("NumericNotStructure", 1:10)
     xx + 1 # vector
     log(xx) # vector
     sample(xx) # vector

