Attach a demand database (lazy load) as a new environment.
1 2 3 4 5 6 7 8 9
position in search path to attach DB
character to prefix all symbols with
character to postfix all symbols with
should objects be cached in memory
should objects be cached in on disk
directory to use for
An experimental function to allow access to remote objects without requiring explicit calls to a loading function.
attachSymbols requires a
to define where the data is to come from, as well as what symbols are
attachSymbols calls the method referred to
DDB object. In the default case this is
DDB_Yahoo. See this function for specific details
about the Yahoo implementation.
The individual methods make use of
load the data. This requires a corresponding
Internally, attachSymbols makes use of quantmod's unexported create.bindings to dynamically create active bindings to each symbol listed in the DDB object.
In turn, create.bindings uses one of two R methods to create the binding to the names required. This depends on the cache method requested.
Immediately after a call to attachSymbols, a new environment is attached that contains the names of objects yet to be loaded. This is similar to the lazy-load mechanism in R, though extended to be both more general and easier to use.
It is important to note that no data is loaded at this stage.
What occurs instead is that these symbols now have active bindings
delayedAssign (mem.cache) or
During all future requests for the object(s) in question,
the binding will be used to determine how this data is
loaded into R.
mem.cache will simply load the
data from its corresponding source (as defined by the DDB object)
and leave it in the environment specified in the original call.
The effect of this is to allow lazy-loading of data from
a variety of external sources (Yahoo in the default case).
Once loaded, these are cached in R's memory. Nothing further
differentiates these from standard variables. This also means
that the environment will grow as more symbols are loaded.
file.cache option is set, the data is loaded from
its source the first time the symbol is referenced. The difference
is that the data is then written to a temporary file and maintained
there. Data is loaded and subsequently removed upon each
request for the object. See
makeActiveBinding for details
of how this occurs at the R level.
A primary advantage of using the file.cache option is the ability to maintain hundreds or thousands of objects in your current session without using memory, or explicitly loading and removing. The main downside of this approach is the that data must be loaded from disk each time, with the corresponding (if generally negligible) overhead of file access.
This function is new, and all aspects may change in the near future.
Jeffrey A. Ryan
Luke's stuff and Mark Brevington and Roger Peng
1 2 3 4 5 6 7
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.