Defaults-package {Defaults} | R Documentation |
Set, Get, and Import Global Function Defaults
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 ValuesDefaults 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
.
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.
Jeffrey A. Ryan
Maintainer: Jeff Ryan <jeff.a.ryan@gmail.com>
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