Learn R Programming

tidyfinance (version 0.4.3)

download_data_fred: Download and Process Data from FRED

Description

This function downloads a specified data series from the Federal Reserve Economic Data (FRED) website, processes the data, and returns it as a tibble.

Usage

download_data_fred(series, start_date = NULL, end_date = NULL)

Value

A tibble containing the processed data with three columns:

date

The date corresponding to the data point.

value

The value of the data series at that date.

series

The FRED series ID corresponding to the data.

Arguments

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.

Details

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.

Examples

Run this code
# \donttest{
  download_data_fred("CPIAUCNS")
  download_data_fred(c("GDP", "CPIAUCNS"), "2010-01-01", "2010-12-31")
# }

Run the code above in your browser using DataLab