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

