Description Details Note Author(s) Examples
Set, Get, and Import Global Function Defaults
Package: | Defaults |
Type: | Package |
Version: | 2.0-0 |
Date: | 2014-11-23 |
LazyLoad: | yes |
License: | GPL 2 or later |
Index:
1 2 3 4 5 6 7 8 | useDefaults DEFUNCT: Enable Global Default Check by Function
unDefaults DEFUNCT: 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
.
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: Joshua M. Ulrich <josh.m.ulrich@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 | formals(sd) # what _can_ be set
try(sd(c(1:10,NA)),silent=TRUE) # fails
#useDefaults(sd) # DEFUNCT as of 2.0-0
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) # DEFUNCT as of 2.0-0
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.