## ----setup, include = FALSE---------------------------------------------------
library(fred)
key_available <- nzchar(Sys.getenv("FRED_API_KEY"))
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 4.5,
  eval = key_available
)

## -----------------------------------------------------------------------------
library(fred)

## -----------------------------------------------------------------------------
panel <- fred_series(
  c("GDPC1", "UNRATE", "CPIAUCSL"),
  from = "2000-01-01"
)
panel

## -----------------------------------------------------------------------------
growth_panel <- fred_series(
  c("GDPC1", "CPIAUCSL"),
  from = "2010-01-01",
  transform = "yoy_pct"
)
growth_panel

## -----------------------------------------------------------------------------
wide <- fred_series(
  c("UNRATE", "CIVPART", "EMRATIO"),
  from = "2000-01-01",
  format = "wide"
)
head(wide)

## -----------------------------------------------------------------------------
plot(growth_panel, ylab = "% YoY")

## -----------------------------------------------------------------------------
plot(wide, ylab = "%", main = "US labour market")

## ----eval = TRUE--------------------------------------------------------------
fred_catalogue(category = "Inflation")

## ----eval = TRUE--------------------------------------------------------------
fred_catalogue(query = "mortgage")

## ----eval = TRUE--------------------------------------------------------------
fred_browse()

