I'm trying to download CPI data from FRED with tq_get from the tidyquant package.
This code retrieves the data from here: https://fred.stlouisfed.org/series/CPIAUCSL
cpi <- tq_get(x = c("CPIAUCSL"), get = "economic.data")
But the oldest date in the imported table is January 1, 2007. The data on FRED's website goes all the way back to January 1, 1947. Clicking "download" on the page I linked to downloads the entire series. Why doesn't tidyquant and is there a way to specify the desired date range?
By default tq_get()
returns 10-years of data. As @HFBrowning commented, you should add from
and to
arguments to specify a longer time range.
c("CPIAUCSL") %>%
tq_get(get = "economic.data", from="1947-01-01", to="2017-10-02")