View source: R/download_data_fred.R
download_data_fred | R Documentation |
This function downloads a specified data series from the Federal Reserve Economic Data (FRED) website, processes the data, and returns it as a tibble.
download_data_fred(series, start_date = NULL, end_date = NULL)
series |
A character vector specifying the FRED series ID to download. |
start_date |
The start date for filtering the data, in "YYYY-MM-DD" format. |
end_date |
The end date for filtering the data, in "YYYY-MM-DD" format. |
This function constructs the URL based on the provided FRED series ID, performs an HTTP GET request to download the data in CSV format, and processes it to a tidy tibble format. The resulting tibble includes the date, value, and the series ID.
This approach is inspired by quantmod::getSymbolsFRED()
which uses a different wrapper around
the same FRED download data site. If you want to systematically download FRED data via API,
please consider using fredr
package.
A tibble containing the processed data with three columns:
The date corresponding to the data point.
The value of the data series at that date.
The FRED series ID corresponding to the data.
download_data_fred("CPIAUCNS")
download_data_fred(c("GDP", "CPIAUCNS"), "2010-01-01", "2010-12-31")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.