Learn R Programming

fred (version 0.3.1)

fred_cite_series: Generate a citation for a FRED series

Description

Produces a citation string for a single FRED series in BibTeX, plain text, or bibentry form. Works offline by default: the citation falls back to the series ID as the title. Pass fetch_metadata = TRUE to call fred_info() and use the official series title (requires an API key).

Usage

fred_cite_series(
  series_id,
  vintage_date = NULL,
  format = c("bibtex", "text", "bibentry"),
  fetch_metadata = FALSE
)

Value

A character string ("bibtex", "text") or a bibentry object.

Arguments

series_id

Character. A single FRED series ID.

vintage_date

Optional character or Date. Vintage date the data was accessed as of. Defaults to today's date (the "accessed" date).

format

Character. One of "bibtex" (default), "text", or "bibentry" (an R utils::bibentry object).

fetch_metadata

Logical. If TRUE, call fred_info() to fetch the official series title. Requires an API key. Default FALSE.

Details

Cite a specific vintage by passing vintage_date. This is essential for reproducible research: a 2023 GDP figure published in October 2023 may differ materially from the same observation as it appears today.

See Also

Other reproducibility: fred_manifest(), fred_vintage_revisions()

Examples

Run this code
# BibTeX without an API call
fred_cite_series("GDPC1")

# Plain-text citation pinned to a vintage date
fred_cite_series("UNRATE", vintage_date = "2024-06-01", format = "text")

if (FALSE) {
  # Use the official title (requires an API key)
  fred_cite_series("GDPC1", fetch_metadata = TRUE)
}

Run the code above in your browser using DataLab