fred_group {eFRED}R Documentation

Fetch and Create a Panel of Data

Description

Function that fetches data series with related codes and places the results into a long data.frame.

Usage

fred_group(
  id,
  groups,
  type = c("prefix", "postfix", "infix"),
  key = NULL,
  name = NULL,
  grp_name = "group",
  realtime_start = NULL,
  realtime_end = NULL
)

fred_state(
  id,
  type = c("prefix", "postfix", "infix"),
  key = NULL,
  name = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

id

character string containing the common series id segment

groups

character vector denoting the variation in the series

type

how should the group vectors be combined with the id? "prefix" places the groups before the id, "postfix" after the id, and use "infix" to place the group code between values in id *(requires id to be a length 2 character vector)*

key

32 character lower-cased alpha-numeric character string

name

character string describing the name of the value column. If NULL, the id will be used.

grp_name

character string describing the name of the group column. Defaults to "group".

realtime_start, realtime_end

character date strings of format "YYY-MM-DD" used obtain information that was known during the specified time period. If empty, the latest update of the information is used.

Details

The fred_group command is convenience function that searches for many different series at once and places them in a panel. This is similar to the fred command except that it can be more convenient when the series are related to each other. For example, the statewide unemployment rates from the Bureau of Labor Statistics have all codes with the format: "<State Abbreviation><UR>". If state abbreviations are located in variable state.abb, then the command fred_group("UR", state.abb, "prefix", key) would search place all unemployment rates into a data.frame.

fred_state is a wrapper around fred_group with the state abbreviations used for groups and with the group column "state".

Value

data.frame

Functions

Examples

## Not run: 
api_key <- "abcdefghijklmnopqrstuvwxyz123456"

# Panel of Unemployment Rates Across States
unemploy <- fred_state("UR", key = api_key)
unemploy

# Panel of Constant GDP per Capita by Country
GDP <- fred_group("NYGDPPCAPKD", eFRED::countries, type="postfix",
  key=api_key, name= "gdppc", grp_name="country")
GDP

## End(Not run)


[Package eFRED version 0.1.0 Index]