Defaults-package          package:Defaults          R Documentation

_C_r_e_a_t_e _G_l_o_b_a_l _F_u_n_c_t_i_o_n _D_e_f_a_u_l_t_s

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

     Set, Get, and Import Global Function Defaults

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


       Package:   Defaults
       Type:      Package
       Version:   1.1-1
       Date:      2007-08-17
       LazyLoad:  yes
       License:   GPL 2 or later
       Packaged:  Sun Jul 25 10:03:19 2007; jryan
       Built:     R 2.5.0; ; 2007-07-25 10:03:38; unix

     Index:


     useDefaults             Enable Global Default Check by Function
     unDefaults              Disable Global Default Check by Function

     getDefaults             Show Global Defaults List by Function
     setDefaults             Create Global Defaults List by Function
     unsetDefaults           Remove All Global Defaults by Function

     importDefaults          Import Global Default Argument Values

     'Defaults' makes the use of globally specified defaults, on a
     per-function basis, available to _all_ functions written in R.

     Through the use of 'importDefaults' which can be hard coded into a
     function by the function author, or dynamically enabled for _any_
     visible function through 'useDefaults', a user can now override
     the author specified defaults as returned by 'formals' by a call
     to 'setDefaults'.

_N_o_t_e:

     It is important to note that only exported functions may have
     defaults set, which _should not_ be an issue, as they are the only
     user callable functions.

     A big thank you to John Chambers and Dirk Eddelbuettel who pointed
     out my mishandling of functions with namespaces calling internal
     non-exported functions. A new implementation of 'useDefaults' now
     handles this correctly.

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

     Jeffrey A. Ryan

     Maintainer: Jeff Ryan <jeff.a.ryan@gmail.com>

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

     formals(sd)                       # what _can_ be set
     try(sd(c(1:10,NA)),silent=TRUE)   # fails

     useDefaults(sd)                   # not necessary - setDefaults will call
     setDefaults(sd, na.rm=TRUE) 
     getDefaults(sd)                   # what _has_ been set

     sd(c(1:10,NA))                    # works!

     unsetDefaults(sd, confirm=FALSE)  # removes previously set default
     unDefaults(sd)                    # unecessary, as unsetDefaults calls automatically

