Introduction

This vignette is intended to introduce the user to fredr functions for the Tags endpoint of the FRED API.

FRED series are assigned tags as an attribute for classification. Each FRED tag is identified by a string ID. For example:

  • “annual”, “monthly”
  • “census”, “bls”
  • “usa”, “county”
  • “manufacturing”, “exports”, “households”
  • “sa” (i.e. “seasonally adjusted”)

The following examples illustrate usage of the Tags endpoint functions in fredr.

Get series tags

The function fredr_tags() returns a list of tags matching the request. The data returned is a tibble in which each row represents a FRED tag. For example, running fredr_tags() without any parameters returns the top 1000 FRED tags ordered by number of series who are assigned the tag (but here we limit to just 10):

fredr_tags(limit = 10)
#> # A tibble: 10 × 6
#>    name                           group_id notes created popularity series_count
#>    <chr>                          <chr>    <chr> <chr>        <int>        <int>
#>  1 nsa                            seas     "Not… 2012-0…         99       726692
#>  2 usa                            geo      "Uni… 2012-0…        100       655988
#>  3 public domain: citation reque… cc        NA   2018-1…         99       609670
#>  4 annual                         freq     ""    2012-0…         88       490336
#>  5 county                         geot     "Cou… 2012-0…         76       330784
#>  6 nation                         geot     ""    2012-0…         99       262252
#>  7 census                         src      "Cen… 2012-0…         79       237162
#>  8 monthly                        freq     ""    2012-0…         94       214574
#>  9 copyrighted: citation required cc        NA   2018-1…         87       206936
#> 10 bls                            src      "Bur… 2012-0…         88       175632

To return specific tags by tag name, specify multiple tags in a single string by delimiting with a semicolon:

fredr_tags(tag_names = "gdp;oecd", limit = 10)
#> # A tibble: 2 × 6
#>   name  group_id notes                           created popularity series_count
#>   <chr> <chr>    <chr>                           <chr>        <int>        <int>
#> 1 gdp   gen      Gross Domestic Product          2012-0…         81        74166
#> 2 oecd  src      Org. for Economic Co-operation… 2012-0…         75        63930

Return tags for a given group ID:

fredr_tags(
  tag_group_id = "geo",
  limit = 50L
)
#> # A tibble: 50 × 6
#>    name  group_id notes                    created       popularity series_count
#>    <chr> <chr>    <chr>                    <chr>              <int>        <int>
#>  1 usa   geo      United States of America 2012-02-27 1…        100       655592
#>  2 tx    geo      Texas                    2012-02-27 1…         59        35424
#>  3 ga    geo      Georgia (U.S. state)     2012-02-27 1…         51        20796
#>  4 ca    geo      California               2012-02-27 1…         62        18054
#>  5 nc    geo      North Carolina           2012-02-27 1…         52        17440
#>  6 va    geo      Virginia                 2012-02-27 1…         50        17420
#>  7 il    geo      Illinois                 2012-02-27 1…         50        16426
#>  8 oh    geo      Ohio                     2012-02-27 1…         50        16236
#>  9 ky    geo      Kentucky                 2012-02-27 1…         45        15680
#> 10 in    geo      Indiana                  2012-02-27 1…         49        15334
#> # ℹ 40 more rows

Search for tags by text:

fredr_tags(search_text = "unemployment")
#> # A tibble: 2 × 6
#>   name         group_id notes                    created popularity series_count
#>   <chr>        <chr>    <chr>                    <chr>        <int>        <int>
#> 1 unemployment gen      ""                       2012-0…         72        32582
#> 2 nairu        gen      "Non-Accelerating Infla… 2012-0…         18            2

Note that the example above searches for tags matching "unemployment". To search for the set of series with tags matching "unemployment", use fredr_series_search_tags():

fredr_series_search_tags(
  series_search_text = "unemployment",
  limit = 100L
)
#> # A tibble: 100 × 6
#>    name                           group_id notes created popularity series_count
#>    <chr>                          <chr>    <chr> <chr>        <int>        <int>
#>  1 nsa                            seas     "Not… 2012-0…         99        44396
#>  2 usa                            geo      "Uni… 2012-0…        100        41728
#>  3 public domain: citation reque… cc        NA   2018-1…         99        41412
#>  4 bls                            src      "Bur… 2012-0…         88        37482
#>  5 unemployment                   gen      ""    2012-0…         72        32748
#>  6 county                         geot     "Cou… 2012-0…         76        28198
#>  7 annual                         freq     ""    2012-0…         88        24022
#>  8 household survey               gen      "Cur… 2012-0…         62        19848
#>  9 monthly                        freq     ""    2012-0…         94        18814
#> 10 rate                           gen      ""    2012-0…         85        14938
#> # ℹ 90 more rows

The function fredr_related_tags() returns a list of tags related to the set of tags matching the request. The data returned is a tibble in which each row represents a tag related to the tags specified in tag_names. For example, to get the set of tags related to the tags "monetary aggregates" and "weekly":

fredr_related_tags(tag_names = "monetary aggregates;weekly")
#> # A tibble: 16 × 6
#>    name                           group_id notes created popularity series_count
#>    <chr>                          <chr>    <chr> <chr>        <int>        <int>
#>  1 nation                         geot     ""    2012-0…         99           14
#>  2 usa                            geo      "Uni… 2012-0…        100           14
#>  3 frb                            src      "Boa… 2012-0…         81           12
#>  4 h6                             rls      "H.6… 2012-0…         50           12
#>  5 nsa                            seas     "Not… 2012-0…         99           12
#>  6 public domain: citation reque… cc        NA   2018-1…         99           12
#>  7 discontinued                   gen      ""    2012-0…         66           10
#>  8 m3                             gen      "M3 … 2012-0…         40            6
#>  9 m1                             gen      "M1 … 2012-0…         46            4
#> 10 copyrighted: citation required cc        NA   2018-1…         87            2
#> 11 currency                       gen      ""    2012-0…         61            2
#> 12 frb stl                        src      "St.… 2012-0…         68            2
#> 13 funds                          gen       NA   2020-0…         30            2
#> 14 m2                             gen      "M2 … 2012-0…         44            2
#> 15 mzm                            gen      "MZM… 2012-0…         24            2
#> 16 sa                             seas     "Sea… 2012-0…         89            2

To filter these results to tags belonging to the “General” tag group:

fredr_related_tags(
  tag_names = "monetary aggregates;weekly",
  tag_group_id = "gen"
)
#> # A tibble: 6 × 6
#>   name         group_id notes             created        popularity series_count
#>   <chr>        <chr>    <chr>             <chr>               <int>        <int>
#> 1 discontinued gen      ""                2012-02-27 10…         66           14
#> 2 m3           gen      "M3 Money Stock"  2012-02-27 10…         40            6
#> 3 m1           gen      "M1 Money Stock"  2012-02-27 10…         46            4
#> 4 m2           gen      "M2 Money Stock"  2012-02-27 10…         44            4
#> 5 mzm          gen      "MZM Money Stock" 2012-02-27 10…         24            4
#> 6 funds        gen       NA               2020-05-11 13…         30            2

To filter these results even further, keep only the tags matching the string "money stock":

fredr_related_tags(
  tag_names = "monetary aggregates;weekly",
  tag_group_id = "gen",
  search_text = "money stock"
)
#> # A tibble: 3 × 6
#>   name  group_id notes          created                popularity series_count
#>   <chr> <chr>    <chr>          <chr>                       <int>        <int>
#> 1 m3    gen      M3 Money Stock 2012-02-27 10:18:19-06         40           12
#> 2 m1    gen      M1 Money Stock 2012-02-27 10:18:19-06         46            6
#> 3 m2    gen      M2 Money Stock 2012-02-27 10:18:19-06         44            4

Get series by tag names

The function fredr_tags_series() returns a list of series assigned tags matching the request. As with the functions for the Series endpoint, the data returned is a tibble in which each row represents a series. For example, to get all series tagged with "gdp":

fredr_tags_series(tag_names = "gdp")
#> # A tibble: 1,000 × 16
#>    id        realtime_start realtime_end title observation_start observation_end
#>    <chr>     <chr>          <chr>        <chr> <chr>             <chr>          
#>  1 A001RD3A… 2023-04-17     2023-04-17   Gros… 1929-01-01        2022-01-01     
#>  2 A001RG3A… 2023-04-17     2023-04-17   Gros… 1929-01-01        2022-01-01     
#>  3 A001RI1A… 2023-04-17     2023-04-17   Gros… 1930-01-01        2022-01-01     
#>  4 A001RI1Q… 2023-04-17     2023-04-17   Gros… 1947-04-01        2022-10-01     
#>  5 A001RL1A… 2023-04-17     2023-04-17   Real… 1930-01-01        2022-01-01     
#>  6 A001RL1Q… 2023-04-17     2023-04-17   Real… 1947-04-01        2022-10-01     
#>  7 A001RO1Q… 2023-04-17     2023-04-17   Real… 1948-01-01        2022-10-01     
#>  8 A001RP1A… 2023-04-17     2023-04-17   Gros… 1930-01-01        2022-01-01     
#>  9 A001RP1Q… 2023-04-17     2023-04-17   Gros… 1947-04-01        2022-10-01     
#> 10 A001RV1A… 2023-04-17     2023-04-17   Gros… 1930-01-01        2022-01-01     
#> # ℹ 990 more rows
#> # ℹ 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 get the top 100 most popular non-quarterly series tagged with "gdp":

fredr_tags_series(
  tag_names = "gdp",
  exclude_tag_names = "quarterly",
  order_by = "popularity",
  limit = 100L
)
#> # A tibble: 100 × 16
#>    id        realtime_start realtime_end title observation_start observation_end
#>    <chr>     <chr>          <chr>        <chr> <chr>             <chr>          
#>  1 RKMTACCF… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  2 VAACCFDQ… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  3 AZADMINW… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  4 TNADMINW… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  5 WVAGRQGSP 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  6 NVARTENT… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  7 GLAKARTE… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  8 IDCONSTQ… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#>  9 IACONSTQ… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#> 10 ORCONSTQ… 2023-04-17     2023-04-17   Chai… 1997-01-01        2022-01-01     
#> # ℹ 90 more rows
#> # ℹ 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>