Learn R Programming

quantmod (version 0.4-6)

Defaults: Manage Default Argument Values for quantmod Functions

Description

Use globally specified defaults, if set, in place of formally specified default argument values. Allows user to specify function defaults different than formally supplied values, e.g. to change poorly performing defaults, or satisfy a different preference.

Usage

setDefaults(name, ...) unsetDefaults(name, confirm = TRUE) getDefaults(name = NULL, arg = NULL) importDefaults(calling.fun)

Arguments

name
name of function, quoted or unquoted
...
name=value default pairs
confirm
prompt before unsetting defaults
arg
values to retrieve
calling.fun
name of function to act upon

Value

Details

See Also

options

Examples

Run this code
my.fun <- function(x=3)
{
  importDefaults('my.fun')
  x^2
}

my.fun()        # returns 9

setDefaults(my.fun, x=10)
my.fun()        # returns 100
my.fun(x=4)     # returns 16

getDefaults(my.fun)
formals(my.fun)
unsetDefaults(my.fun, confirm=FALSE)
getDefaults(my.fun)

my.fun()        # returns 9

Run the code above in your browser using DataLab