new                 package:methods                 R Documentation

_G_e_n_e_r_a_t_e _a_n _O_b_j_e_c_t _f_r_o_m _a _C_l_a_s_s

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

     Given the the name or the definition of a class, plus optionally
     data to be included in the object, `new' returns an object from
     that class.

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

     new(Class, ..., .Force=FALSE)

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

   Class: Either the name of a class (the usual case) or the object
          describing the class (e.g., the value returned by
          `getClass'). 

     ...: Data to include in the new object.  Named arguments
          correspond to slots in the class definition. Unnamed
          arguments must be objects from classes that this class
          extends.

  .Force: Normally, an attempt to apply `new' to a virtual or an
          undefined class generates an error.  If `.Force' is `TRUE',
          an ``empty'' object is returned instead.  Users are very
          unlikely to need this argument. 

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

     The function begins by copying the prototype object from the class
     definition.  Then information is inserted according to the ...
     arguments, if any, first from the superclasses (the unnamed
     arguments) then from the named slots.  Thus, explicit slots
     override inherited information for the same slot, regardless of
     the order in which the arguments appear.

     Note that the basic vector classes, `"numeric"', etc. are
     implicitly defined, so one can use `new' for these classes.

_A_u_t_h_o_r(_s):

     John Chambers

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

     The web page <URL: http://www.omegahat.org/RSMethods/index.html>
     is the primary documentation.

     The functions in this package emulate the facility for classes and
     methods described in Programming with Data, (John M. Chambers,
     Springer, 1998).  See this book for further details and examples.

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

     Classes

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

     ## using the definition of class "track" from Classes



     ## a new object with two slots specified
     t1 <- new("track", x = seq(along=ydata), y = ydata)

     # a new object including an object from a superclass, plus a slot
     t2 <- new("trackCurve", t1, smooth = ysmooth)

