Learn R Programming

quantmod (version 0.4-4)

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

  • setDefaultsNone. Used for it's side effect of setting a list of default arguments by function.
  • unsetDefaultsNone. Used for it's side effect of unsetting default arguments by function.
  • getDefaultsA named list of defaults and associated values, similar to formals, but only returning values set by setDefaults for the name function. Calling getDefaults() (without arguments) returns in a character vector of all functions currently having defaults set (by setDefaults).

    This does not imply that the returned function names are able to accept defaults (via importDefaults), rather that they have been set to store user defaults. All values can also be viewed with a call to getOption(name_of_function.Default).

  • importDefaultsNone. Used for its side-effect of loading all non-NULL user- specified default values into the current function's environment, effectively changing the default values passed in the parent function call. Like formally defined defaults in the function definition, default values set by importDefaults take lower precedence than arguments specified by the user in the function call.

Details

[object Object],[object Object],[object Object],[object Object]

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