setGenericS3              package:R.oo              R Documentation

_C_r_e_a_t_e_s _a _g_e_n_e_r_i_c _f_u_n_c_t_i_o_n _i_n _S_3/_U_s_e_M_e_t_h_o_d _s_t_y_l_e

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

     _Note that this method is a internal method called by
     'setMethodS3'() and there is no reason for calling it directly!_

     Creates a generic function in S3/UseMethod style, i.e. setting a
     function with name 'name' that despatch the method 'name' via
     'UseMethod'. If there is already a function named 'name' that
     function is renamed to 'name.default'.

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

     ## Default S3 method:
     setGenericS3(name, envir=parent.frame(), ellipsesOnly=TRUE, dontWarn=getOption("dontWarnPkgs"), enforceRCC=TRUE, ...)

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

    name: The name of the generic function.

   envir: The environment for where this method should be stored.

ellipsesOnly: If 'TRUE', the only arguments in the generic function
          will be '...'.

dontWarn: If a non-generic method with the same name is found it will
          be "renamed" to a default method. If that method is found in
          a package with a name that is _not_ found in 'dontWarn' a
          warning will be produced, otherwise it will be renamed
          silently.

     ...: Not used.

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

     Henrik Bengtsson (<URL: http://www.braju.com/R/>)

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

     To define a method for a class see 'setMethodS3'(). For a thorough
     example of how to use this method see 'Object'.

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

       myCat.matrix <- function(..., sep=", ") {
         cat("A matrix:\n");
         cat(..., sep=sep);
         cat("\n");
       }

       myCat.default <- function(..., sep=", ") {
         cat(..., sep=sep);
         cat("\n");
       }

       setGenericS3("myCat");

       myCat(1:10);
       mat <- matrix(1:10, ncol=5);
       attr(mat, "class") <- "matrix";  # Has to be done as of [R] V1.4.0.
       myCat(mat);

