1. Setting per-instrument default arguments
You just learned and practiced setting new default argument values for getSymbols() and getSymbols() methods. Those settings affected getSymbols() calls, regardless of the symbol. You can also set custom default argument values on a symbol-by-symbol basis using the setSymbolLookup() function.
2. Use setSymbolLookup() to set data source
setSymbolLookup() takes any number of symbol-argument pairs. If you only want to set the default data source for a symbol, you can specify the argument portion as a string naming the data source. For example, if you always want to pull Apple data from Google Finance, you set AAPL to "google".
3. Use setSymbolLookup() to set other arguments
You have to use a named list if you want to specify other arguments, or more than one argument. Here is an example that sets the default data source for MSFT to Google Finance and changes the first date from 2007-01-01 to 2016-01-01. Notice that the name of the symbol is set to a named list of argument name-value pairs, where src equals "google" and from equals January 1, 2016.
4. Save and restore defaults (1)
Like setDefaults(), defaults changed by setSymbolLookup() are stored in R's global options(), so they do not persist across R sessions. But you can use saveSymbolLookup() and loadSymbolLookup() to manage and share your symbol-based defaults. Let's look at an example that sets, saves, and restores defaults.
First, you use setSymbolLookup() to change the data source to Google. Since you're only setting the default data source, you can simply set AAPL to "google". If you want, you can use getSymbolLookup() to verify the new default is set. Then you use saveSymbolLookup() to save your defaults to file.
To unset defaults for a specific symbol, you can simply assign 'NULL' to the symbol in the setSymbolLookup() call.
5. Save and restore defaults (2)
Using getSymbolLookup(), you can see that the default is no longer set. Now you can use loadSymbolLookup() to restore the settings you saved.
6. Let's practice!
Now it's time to practice customizing getSymbols() behavior for individual instruments.