FRED Tags

library(fredr)

knitr::opts_chunk$set(
  fig.width = 7,
  fig.height = 5,
  eval = fredr_has_key(),
  cache = TRUE,
  collapse = TRUE,
  comment = "#>"
)

Introduction

library(fredr)

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:

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)

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)

Return tags for a given group ID:

fredr_tags(
  tag_group_id = "geo",
  limit = 50L
)

Search for tags by text:

fredr_tags(search_text = "unemployment")

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
)

Get related series tags

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")

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

fredr_related_tags(
  tag_names = "monetary aggregates;weekly",
  tag_group_id = "gen"
)

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"
)

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")

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
)


Try the fredr package in your browser

Any scripts or data that you put into this service are public.

fredr documentation built on Jan. 30, 2021, 1:06 a.m.