This vignette is intended to introduce the user to fredr
functions for the Categories endpoint of the FRED API.
FRED series are assigned categories. Each FRED category is assigned an integer identifier. For example:
category_id = 10
)category_id = 32992
)category_id = 1
)category_id = 97
)Categories are organized in a hierarchical structure where parent categories contain children categories. All categories are children of the root category (category_id = 0
). The following examples illustrate usage of the Categories endpoint functions in fredr
.
fredr_category()
returns minimal information for a single category specified by category_id
. The data returned is a tibble
in which each row represents a category. The default is the root category.
fredr_category_children()
returns minimal information (child ID, name, and parent ID) for all child categories of the parent category specified by category_id
. The data returned is a tibble
in which each row represents child category of the parent specified. The default is the root category.
fredr_category_children()
#> # A tibble: 8 x 3
#> id name parent_id
#> * <int> <chr> <int>
#> 1 32991 Money, Banking, & Finance 0
#> 2 10 Population, Employment, & Labor Markets 0
#> 3 32992 National Accounts 0
#> 4 1 Production & Business Activity 0
#> 5 32455 Prices 0
#> 6 32263 International Data 0
#> 7 3008 U.S. Regional Data 0
#> 8 33060 Academic Data 0
fredr_category_children(category_id = 1L)
#> # A tibble: 12 x 3
#> id name parent_id
#> * <int> <chr> <int>
#> 1 32262 Business Cycle Expansions & Contractions 1
#> 2 32436 Construction 1
#> 3 33490 Finance Companies 1
#> 4 32216 Health Insurance 1
#> 5 97 Housing 1
#> 6 3 Industrial Production & Capacity Utilization 1
#> 7 32429 Manufacturing 1
#> 8 6 Retail Trade 1
#> 9 33441 Services 1
#> 10 33492 Technology 1
#> 11 33202 Transportation 1
#> 12 33203 Wholesale Trade 1
fredr_category_series()
returns detailed information for the FRED series belonging to the category specified by category_id
. The data returned is a tibble
in which each row represents a series belonging to the category specified. The default is the root category. For example, to get the top 100 quarterly series in the “Housing” category, ordering the results so that the most recently updated series appear first:
fredr_category_series(
category_id = 97L, # Housing
limit = 100L,
order_by = "last_updated",
filter_variable = "frequency",
filter_value = "Quarterly"
)
#> # A tibble: 25 x 16
#> id realtime_start realtime_end title observation_sta… observation_end
#> * <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 ETOT… 2018-07-22 2018-07-22 Hous… 2000-04-01 2018-01-01
#> 2 RHOR… 2018-07-22 2018-07-22 Home… 1965-01-01 2018-01-01
#> 3 RRVR… 2018-07-22 2018-07-22 Rent… 1956-01-01 2018-01-01
#> 4 EOWN… 2018-07-22 2018-07-22 Hous… 2000-04-01 2018-01-01
#> 5 EREN… 2018-07-22 2018-07-22 Hous… 2000-04-01 2018-01-01
#> 6 ERNT… 2018-07-22 2018-07-22 Hous… 2000-04-01 2018-01-01
#> 7 ESAL… 2018-07-22 2018-07-22 Hous… 2000-04-01 2018-01-01
#> 8 EVAC… 2018-07-22 2018-07-22 Hous… 2000-04-01 2018-01-01
#> 9 RHVR… 2018-07-22 2018-07-22 Home… 1956-01-01 2018-01-01
#> 10 RSAH… 2018-07-22 2018-07-22 Home… 1980-01-01 2018-01-01
#> # ... with 15 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>
To return all series in the “National Accounts” tagged with “usa” and not “gnp”, ordering the results such that higher frequency series appear first:
fredr_category_series(
category_id = 32992L, # National Accounts
order_by = "frequency",
sort_order = "desc",
tag_names = "usa",
exclude_tag_names = "gnp"
)
#> # A tibble: 4 x 16
#> id realtime_start realtime_end title observation_sta… observation_end
#> * <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 PCRG… 2018-07-22 2018-07-22 Tota… 2001-01-01 2016-01-01
#> 2 NGMP… 2018-07-22 2018-07-22 Tota… 2001-01-01 2016-01-01
#> 3 RGMP… 2018-07-22 2018-07-22 Tota… 2001-01-01 2016-01-01
#> 4 QGMP… 2018-07-22 2018-07-22 Tota… 2001-01-01 2016-01-01
#> # ... 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>