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)

