Description Usage Arguments Value API Documentation See Also Examples
Given a series ID, return observations of that series as a tibble
object.
fredr()
is an alias for fredr_series_observations()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | fredr_series_observations(
series_id,
...,
observation_start = NULL,
observation_end = NULL,
frequency = NULL,
aggregation_method = NULL,
limit = NULL,
offset = NULL,
sort_order = NULL,
units = NULL,
realtime_start = NULL,
realtime_end = NULL,
vintage_dates = NULL,
output_type = NULL
)
fredr(
series_id,
...,
observation_start = NULL,
observation_end = NULL,
frequency = NULL,
aggregation_method = NULL,
limit = NULL,
offset = NULL,
sort_order = NULL,
units = NULL,
realtime_start = NULL,
realtime_end = NULL,
vintage_dates = NULL,
output_type = NULL
)
|
series_id |
A string ID for the FRED series. |
... |
These dots only exist for future extensions and should be empty. |
observation_start |
A |
observation_end |
A |
frequency |
A string representing a lower frequency to aggregate to. Defaults to no frequency aggregation. Possible values are:
|
aggregation_method |
A string representing the aggregation method
used for frequency aggregation. This parameter has no affect is
|
limit |
An integer limit on the maximum number of results to return.
Defaults to |
offset |
An integer used in conjunction with |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
units |
A string indicating the data value transformation.
Defaults to
|
realtime_start |
A |
realtime_end |
A |
vintage_dates |
A vector of |
output_type |
An integer indicating the output type. Not used unless
|
A tibble
object with observation dates and values.
fredr_series_search_text()
,
fredr_series_search_id()
, fredr_series_search_tags()
,
fredr_series_search_related_tags()
, fredr_series()
, fredr_series_categories()
,
fredr_series_release()
, fredr_series_tags()
, fredr_series_updates()
,
fredr_series_vintagedates()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | if (fredr_has_key()) {
# Observations for "UNRATE" series between 1980 and 2000. Units are in terms
# of change from previous observation.
fredr(
series_id = "UNRATE",
observation_start = as.Date("1980-01-01"),
observation_end = as.Date("2000-01-01"),
units = "chg"
)
# All observations for "OILPRICE" series. The data is first aggregated by
# quarter by taking the average of all observations in the quarter then
# transformed by taking the natural logarithm.
fredr(
series_id = "OILPRICE",
frequency = "q",
aggregation_method = "avg",
units = "log"
)
# To retrieve values for multiple series, use purrr's map_dfr() function.
if (requireNamespace("purrr", quietly = TRUE)) {
library(purrr)
purrr::map_dfr(c("UNRATE", "OILPRICE"), fredr)
# Using purrr::pmap_dfr() allows you to use varying optional parameters
params <- list(
series_id = c("UNRATE", "OILPRICE"),
frequency = c("m", "q")
)
purrr::pmap_dfr(
.l = params,
.f = ~ fredr(series_id = .x, frequency = .y)
)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.