Exercise

Introducing Quandl()

Similar to how the quantmod package provides getSymbols() to import data from various sources, the Quandl package provides access to the Quandl databases via one simple function: Quandl().

Recall that getSymbols() uses the Symbols and src arguments to specify the instrument and data source, respectively. The Quandl() function specifies both the data source and the instrument via its code argument, in the form "DATABASE/DATASET".

Two other ways Quandl() differs from getSymbols() are:

  1. Quandl() returns a data.frame by default.
  2. Quandl() will not automatically assign the data to an object.

If you plan on importing a lot of data using Quandl(), you might consider opening a free account with them in order to get an API key.

Instructions

100 XP
  • Load the Quandl package using the library() function.
  • Now use the Quandl() function to download U.S. GDP data from FRED and assign it to an object, gdp (the Quandl code is "FRED/GDP").
  • Use the str() function to view the structure of the gdp object.