| fred_series | R Documentation |
The main function in the package. Downloads time series observations from FRED and returns a tidy data frame. Multiple series can be fetched in a single call.
fred_series(
series_id,
from = NULL,
to = NULL,
units = "lin",
frequency = NULL,
aggregation = "avg",
cache = TRUE
)
series_id |
Character. One or more FRED series IDs (e.g. |
from |
Optional start date. Character ( |
to |
Optional end date. Character ( |
units |
Character. Unit transformation to apply. Default |
frequency |
Character. Frequency aggregation. One of |
aggregation |
Character. Aggregation method when |
cache |
Logical. If |
FRED supports server-side unit transformations via the units argument.
This avoids the need to compute growth rates or log transforms locally.
Supported values:
"lin" -levels (no transformation, the default)
"chg" -change from previous period
"ch1" -change from one year ago
"pch" -percent change from previous period
"pc1" -percent change from one year ago
"pca" -compounded annual rate of change
"cch" -continuously compounded rate of change
"cca" -continuously compounded annual rate of change
"log" -natural log
A data frame with columns:
Date. The observation date.
Character. The FRED series identifier.
Numeric. The observation value.
Other series:
fred_info(),
fred_search(),
fred_updates(),
fred_vintages()
op <- options(fred.cache_dir = tempdir())
# Single series
gdp <- fred_series("GDP")
# Multiple series
macro <- fred_series(c("GDP", "UNRATE", "CPIAUCSL"))
# With transformation: year-on-year percent change
gdp_growth <- fred_series("GDP", units = "pc1")
# Aggregate daily to monthly
rates <- fred_series("DGS10", frequency = "m")
options(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.