fred_set

Purpose

Set one (or more) parameters for a given FRED API call. This function can both create a parameter or update an existing parameter set if the last argument is provided.

Use of this function is optional as all arguments can be specified inline with any associated FRED API call.

Format

x = fred_set(key, value[, keyN, valueN[, ...[, existing_map]]])
Parameters
  • key (string) – The parameter name to set.

  • value (Dataframe) – The parameter value to set. If this paramater is a vector, it is converted to an array before being sent to the FRED API.

  • existing_map – Optional. An existing map to update. If not specified, a new map is returned.

Returns

x (Dataframe) – Parameter map.

Examples

Example with a single parameter

args = fred_set("realtime_start", "1960-01-01");
x = fred_load("GNPCA", args);

the first 5 rows of x will be:

      date            GNPCA
1929-01-01        181.80000
1929-01-01        203.60000
1929-01-01        314.70000
1929-01-01        315.70000
1929-01-01        709.60000

Example with multiple parameters

args = fred_set("realtime_start", "1980-01-01");
args = fred_set("realtime_end", "1989-12-31", args);
x = fred_load("GNPCA", args);

the first 5 rows of x will be:

      date            GNPCA
1929-01-01        314.70000
1929-01-01        315.70000
1929-01-01        709.60000
1930-01-01        285.20000
1930-01-01        285.60000

Example with multiple parameters simultaneously

args = fred_set("realtime_start", "1980-01-01", "realtime_end", "1989-12-31");
x = fred_load("GNPCA", args);

the first 5 rows of x will be:

      date            GNPCA
1929-01-01        314.70000
1929-01-01        315.70000
1929-01-01        709.60000
1930-01-01        285.20000
1930-01-01        285.60000