[R-SIG-Finance] Determining optional parameters
Brian G. Peterson
brian at braverock.com
Tue Jun 5 18:42:38 CEST 2012
On Tue, 2012-06-05 at 08:40 -0700, dae wrote:
> Is there a systematic way to determine optional parameters for a function?
> By optional, I am referring to those which are in the "..." portion of the
> function definition.
>
> For example, quantmod's getSymbols help file shows this:
>
> getSymbols(Symbols = NULL,
> env = .GlobalEnv,
> reload.Symbols = FALSE,
> verbose = FALSE,
> warnings = TRUE,
> src = "yahoo",
> symbol.lookup = TRUE,
> auto.assign = TRUE,
> ...)
>
> In /library/blotter/demo/turtles.R, it uses getSymbols
> in this way:
>
> getSymbols(symbols, index.class="POSIXct", from=initDate, source="yahoo")
>
> "symbols" is created earlier in the code:
> symbols = c("XLF", "XLP", "XLE")
> and due to it's position in the parameter list, is presumably equivalent to:
>
> getSymbols(Symbols=symbols, index.class="POSIXct", from=initDate,
> source="yahoo")
>
> but index.class, from, and source are not in the function definition. How
> do I systematically explore a function's optional parameters?
In this case, what's happening is that getSymbols is dispatching to the
function getSymbols.yahoo identified by the 'src' argument.
If you do
?getSymbols.yahoo
you can see the documentation for the underlying function.
dots ... are typically used, as in this case, to pass things to other
lower-level functions. Typical examples would include things like plot
functions, other encapsulated analytics (TTR functions, lm, etc.), or
similar. Typically, they will not be used for direct arguments to the
function you've called.
HTH,
- Brian
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list