This vignette is intended to introduce the user to fredr
functions for the Series endpoint of the FRED API.
FRED series are the primary data objects in the FRED database. Each FRED series is assigned a string identifier. For example:
series_id = "UNRATE"
)series_id = "GNPCA"
)series_id = "FEDFUNDS"
)FRED series are assigned categories and tags attributes for organization and classification. The following examples illustrate usage of the Series endpoint functions in fredr
.
The function fredr()
, an alias for fredr_series_observations()
, is the core function in fredr
for fetching FRED data series. See the Get started article and ?fredr()
for many usage examples.
fredr(
series_id = "UNRATE",
observation_start = as.Date("1990-01-01")
)
#> # A tibble: 342 x 3
#> date series_id value
#> <date> <chr> <dbl>
#> 1 1990-01-01 UNRATE 5.4
#> 2 1990-02-01 UNRATE 5.3
#> 3 1990-03-01 UNRATE 5.2
#> 4 1990-04-01 UNRATE 5.4
#> 5 1990-05-01 UNRATE 5.4
#> 6 1990-06-01 UNRATE 5.2
#> 7 1990-07-01 UNRATE 5.5
#> 8 1990-08-01 UNRATE 5.7
#> 9 1990-09-01 UNRATE 5.9
#> 10 1990-10-01 UNRATE 5.9
#> # ... with 332 more rows
Use fredr_series_search_text()
to search for a series by text in the series description. The data returned is a tibble
where each row represents series with description text that matches the text specified by search_text
. For example, to search for series with description text that matches “UNRATE”:
fredr_series_search_text(
search_text = "unemployment",
limit = 100L
)
#> # A tibble: 100 x 16
#> id realtime_start realtime_end title observation_sta… observation_end
#> * <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 UNRA… 2018-07-22 2018-07-22 Civi… 1948-01-01 2018-06-01
#> 2 UNRA… 2018-07-22 2018-07-22 Civi… 1948-01-01 2018-06-01
#> 3 NROU 2018-07-22 2018-07-22 Natu… 1949-01-01 2027-10-01
#> 4 UNEM… 2018-07-22 2018-07-22 Unem… 1948-01-01 2018-06-01
#> 5 M089… 2018-07-22 2018-07-22 Unem… 1929-04-01 1942-06-01
#> 6 Q089… 2018-07-22 2018-07-22 Unem… 1940-04-01 1946-10-01
#> 7 M089… 2018-07-22 2018-07-22 Unem… 1940-01-01 1946-12-01
#> 8 M089… 2018-07-22 2018-07-22 Unem… 1947-01-01 1966-12-01
#> 9 LNS1… 2018-07-22 2018-07-22 Unem… 1948-01-01 2018-06-01
#> 10 U6RA… 2018-07-22 2018-07-22 Tota… 1994-01-01 2018-06-01
#> # ... with 90 more rows, and 10 more variables: frequency <chr>,
#> # frequency_short <chr>, units <chr>, units_short <chr>,
#> # seasonal_adjustment <chr>, seasonal_adjustment_short <chr>,
#> # last_updated <chr>, popularity <int>, group_popularity <int>,
#> # notes <chr>
Use fredr_series_search_id()
to search for a series by character ID of the series. The data returned is a tibble
where each row represents series with an ID that matches the text specified by search_text
. For example, to search for series with an ID that matches “UNRATE”:
fredr_series_search_id(
search_text = "UNRATE",
limit = 100L
)
#> # A tibble: 16 x 16
#> id realtime_start realtime_end title observation_sta… observation_end
#> * <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 UNRA… 2018-07-22 2018-07-22 Civi… 1948-01-01 2018-06-01
#> 2 UNRA… 2018-07-22 2018-07-22 FOMC… 2018-01-01 2020-01-01
#> 3 UNRA… 2018-07-22 2018-07-22 Long… 2009-02-18 2018-06-13
#> 4 UNRA… 2018-07-22 2018-07-22 FOMC… 2018-01-01 2020-01-01
#> 5 UNRA… 2018-07-22 2018-07-22 Long… 2009-02-18 2018-06-13
#> 6 UNRA… 2018-07-22 2018-07-22 FOMC… 2018-01-01 2020-01-01
#> 7 UNRA… 2018-07-22 2018-07-22 Long… 2009-02-18 2018-06-13
#> 8 UNRA… 2018-07-22 2018-07-22 FOMC… 2018-01-01 2020-01-01
#> 9 UNRA… 2018-07-22 2018-07-22 Long… 2015-06-17 2018-06-13
#> 10 UNRA… 2018-07-22 2018-07-22 Civi… 1948-01-01 2018-06-01
#> 11 UNRA… 2018-07-22 2018-07-22 FOMC… 2018-01-01 2020-01-01
#> 12 UNRA… 2018-07-22 2018-07-22 Long… 2009-02-18 2018-06-13
#> 13 UNRA… 2018-07-22 2018-07-22 FOMC… 2018-01-01 2020-01-01
#> 14 UNRA… 2018-07-22 2018-07-22 Long… 2009-02-18 2018-06-13
#> 15 UNRA… 2018-07-22 2018-07-22 FOMC… 2018-01-01 2020-01-01
#> 16 UNRA… 2018-07-22 2018-07-22 Long… 2009-02-18 2018-06-13
#> # ... with 10 more variables: frequency <chr>, frequency_short <chr>,
#> # units <chr>, units_short <chr>, seasonal_adjustment <chr>,
#> # seasonal_adjustment_short <chr>, last_updated <chr>, popularity <int>,
#> # group_popularity <int>, notes <chr>
The fredr_series()
function returns information for a single series specified by series_id
. The data returned is a tibble
in which each row represents the series specified. For example, to get information for the UNRATE
series:
fredr_series(series_id = "UNRATE")
#> # A tibble: 1 x 15
#> id realtime_start realtime_end title observation_sta… observation_end
#> * <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 UNRA… 2018-07-22 2018-07-22 Civi… 1948-01-01 2018-06-01
#> # ... with 9 more variables: frequency <chr>, frequency_short <chr>,
#> # units <chr>, units_short <chr>, seasonal_adjustment <chr>,
#> # seasonal_adjustment_short <chr>, last_updated <chr>, popularity <int>,
#> # notes <chr>
Note that there may potentially be more than one row returned if the series has been revised and real time periods are adjusted:
fredr_series(
series_id = "UNRATE",
realtime_start = as.Date("1950-01-01")
)
#> # A tibble: 3 x 15
#> id realtime_start realtime_end title observation_sta… observation_end
#> * <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 UNRA… 1960-03-15 1967-02-08 Civi… 1948-01-01 1966-12-01
#> 2 UNRA… 1967-02-09 2012-02-02 Civi… 1948-01-01 2011-12-01
#> 3 UNRA… 2012-02-03 9999-12-31 Civi… 1948-01-01 2018-06-01
#> # ... with 9 more variables: frequency <chr>, frequency_short <chr>,
#> # units <chr>, units_short <chr>, seasonal_adjustment <chr>,
#> # seasonal_adjustment_short <chr>, last_updated <chr>, popularity <int>,
#> # notes <chr>
The fredr_series_categories()
function returns a list of categories for the series specified by series_id
. The data returned is a tibble
in which each row represents a category that the series belongs to. For example, to get the categories for the UNRATE
series:
The fredr_series_release()
function returns a list of releases that the series specified by series_id
belongs to. The data returned is a tibble
in which each row represents a release that the series belongs to. For example, to get the release for the UNRATE
series:
The fredr_series_updates()
function returns a list of series recently updated on the FRED server. The data returned is a tibble
in which each row represents a series. For example, the default call simply lists 1000 recent updates (the default for the limit
parameter), most recent updates appearing first:
fredr_series_updates()
#> # A tibble: 1,000 x 15
#> id realtime_start realtime_end title observation_sta… observation_end
#> * <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 CBBC… 2018-07-22 2018-07-22 Coin… 2017-12-20 2018-07-22
#> 2 CBLT… 2018-07-22 2018-07-22 Coin… 2016-08-17 2018-07-22
#> 3 CBCC… 2018-07-22 2018-07-22 Coin… 2015-01-01 2018-07-21
#> 4 CBBT… 2018-07-22 2018-07-22 Coin… 2014-12-01 2018-07-22
#> 5 CBET… 2018-07-22 2018-07-22 Coin… 2016-05-18 2018-07-22
#> 6 R250… 2018-07-22 2018-07-22 Russ… 1985-12-31 2018-07-20
#> 7 RTOP… 2018-07-22 2018-07-22 Russ… 1985-12-31 2018-07-20
#> 8 R250… 2018-07-22 2018-07-22 Russ… 1985-12-31 2018-07-20
#> 9 RTOP… 2018-07-22 2018-07-22 Russ… 1985-12-31 2018-07-20
#> 10 RTOP… 2018-07-22 2018-07-22 Russ… 1985-12-31 2018-07-20
#> # ... with 990 more rows, and 9 more variables: frequency <chr>,
#> # frequency_short <chr>, units <chr>, units_short <chr>,
#> # seasonal_adjustment <chr>, seasonal_adjustment_short <chr>,
#> # last_updated <chr>, popularity <int>, notes <chr>
Use the start_time
and end_time
parameters to filter the results by time. For example, to get all the macroeconomic times series updated in the last hour:
The fredr_series_vintagedates()
function returns a sequence of dates in history when the series specified by series_id
was revised or appended to. The data returned is a tibble
where each row is a date. For example, to get the vintage dates for the series UNRATE
: