Save and load symbol lookup table
The previous exercise taught you how to set default arguments on a per-symbol basis, but those settings only last for the current session.
This exercise will teach you how to save and load symbol-based defaults by using saveSymbolLookup()
and loadSymbolLookup()
, respectively. You can use the file
arguments to specify a file to store your defaults.
You can also use the getSymbolLookup()
function to check per-symbol defaults before you try to load data using getSymbols()
.
This exercise is part of the course
Importing and Managing Financial Data in R
Exercise instructions
The source for CP
has already been set to "FRED"
.
- Use
saveSymbolLookup()
to save the symbol lookup table to a file named"my_symbol_lookup.rda"
. - Set the source for
CP
to"yahoo"
using what you learned in the prior exercise. - Use
getSymbolLookup()
to verify that the default source forCP
actually changed from"FRED"
to"yahoo"
. - Now use
loadSymbolLookup()
to load the saved symbol lookup table.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Save symbol lookup table to file
# Set default source for CP to "yahoo"
# Verify the default source is "yahoo" for "CP"
# Load symbol lookup table from file