Haver_legacy {Haver} | R Documentation

## Haver Legacy Functions

### Description

This document describes legacy functions to access Haver Analytics time series databases from R. It also compares the the legacy functions to the recommended `haver` family of functions. Loading the current Haver package includes the superseded legacy functions. Use of the functions described here should only be made if existing R scripts depend on them. In all other cases, we recommend using a new set of functions (see section ‘Old and New Haver Functions’ in `Haver_introduction`).

### Details

This section gives an overview of the legacy `dlx` family of functions.

One or more time series are queried using `dlxGetData` and are returned as `zoo` objects indexed by Date objects. Metadata for one series is queried using `dlxGetInfo`. In order to use these functions you must first set the location of your Haver databases using `dlxSetDbPath`. Some basic examples are provided below:

    ## Load Haver library
    library(Haver)

    ## Set the location of your Haver databases.
    dlxSetDbPath("C:/DLX/data/")

    ## Get the series LANAGRA and GDP from database USECON.
    dlxGetData(c("lanagra", "gdp"), "usecon")

    ## Get the series LANAGRA and GDP from database USECON and
    ## FFED from database WEEKLY
    dlxGetData(c("lanagra", "gdp", "weekly:ffed"), "usecon")

    ## Get the series LANAGRA from database USECON in the date range
    ## 2000:1 to 2010:12
    dlxGetData("lanagra", "usecon", start="2000-01-01", end="2010-12-31")

    ## Get the series LANAGRA from database USECON, convert to quarterly
    ## frequency, and get data in the range 2000:1 to 2010:4
    dlxGetData("lanagra", "usecon", start="2000-01-01", end="2010-12-31",
      frequency="q")

    ## Get metadata about series LANAGRA in database USECON
    dlxGetInfo("lanagra", "usecon")

You can also set the aggregation mode that will be used in calls to `dlxGetData` by using function `dlxSetAggregation`. Options are "strict", "relaxed", and "force". See `?dlxSetAggregation` for details. To see the current aggregation mode, call `dlxGetAggregation`. The default is "strict".
More examples are provided in the help files of the individual `dlx` functions (see the table below for hyperlinks).

### Changes in the Legacy `dlx` Family of Functions

Compared to the previous version of the Haver package, the only changes made are:

- While the return type of data queries is still `zoo`, the zoo package is no longer automatically installed with the Haver package. If you do not have zoo installed and want to use the legacy dlx family of functions, you have to install it yourself (see `install.packages`).

- Some of the help files have been reworked slightly.

- Path settings will be preserved from one R session to the next.

### Differences to the New Functions and Interactions between Old and New Functions

This section highlights the most important differences between the legacy `dlx` family of functions and the recommended `haver` family of functions. The following table gives a quick overview of old and new function names:

legacy `dlx` family | corresponding `haver` family function
`dlxSetDbPath` | `haver.path`
`dlxGetInfo` | `haver.metadata`
`dlxGetData` | `haver.data`
`dlxSetAggregation` |
`dlxGetAggregation` |

The functionality of `dlxSetAggregation` is now incorporated in `haver.data`.

#### Path Setting

`dlxSetDbPath` has been replaced by `haver.path`. Both functions store the database path in a global variable ‘.dlxdbpath’. This means that setting the path using `dlxSetDbPath` will be relevant for the recommended `haver` family of functions. Conversely, setting the path using `haver.path` will also provide the setting for the legacy `dlx` family of functions.

Regardless of which function you use, path settings will be preserved from one R session to the next.

#### Name Changes

The `varnames` argument of `dlxGetData` has been renamed into `codes` for `haver.data`. The casing of metadata fields returned by `dlxGetData` has been changed to be strictly lower case in `haver.metadata`. The metadata field ‘varname’ of `dlxGetData` has been renamed to ‘code’ in `haver.metadata`.

#### Metadata

`dlxGetInfo` only lets you query metadata for one code at a time. `haver.metadata` lets you specify lists of codes, or lets you retrieve metadata for an entire database. In addition, `haver.metadata` returns the information in a more convenient fashion, namely as a `data.frame` or as a `HaverMetaData` object. Both can be filtered, and `data.frame`s from different metadata queries can be appended using `rbind`. The resulting objects can be passed to `haver.data` for data queries.

#### Data Queries

##### Return Types

`haver.data` does not by default return a `zoo` object. Instead, it returns a `HaverData` object. If you want `haver.data` to give you `zoo` objects, you can either set the value of the argument `rtype` to `zoo`, or you can have it return a `HaverData` object first and then coerce it to a `zoo` object using `haver.as.zoo`.

`HaverData` objects can also be coerced into a matrix or a `data.frame`.

##### Metadata Associated with Data Queries

For each data query, `haver.data` automatically retrieves the metadata associated with the series retrieved, as long as you use the default return type `HaverData`. You can access the metadata of the `HaverData` object simply by using `haver.datamd(hd)` which, among other things, gives you a listing of the series descriptors.

##### Data Set Frequency

The `frequency` argument of `dlxGetData` only applied if no series in the query was recorded in a lower frequency. By contrast, the `frequency` argument of `haver.data` always pins down the frequency of the returned data set. If series cannot be aggregated or disaggregated to fit this frequency they get removed from the query.

##### Other

With `haver.data`, you can feed objects created by `haver.metatdata` into the data query.

The time display has also improved. With `haver.data`, you can choose between period display and end-of-period date display.

#### Aggregation Mode

The recommended `haver` family of functions has no direct counterparts to `dlxSetAggregation` and `dlxGetAggregation`. The aggregation mode is instead determined by the `aggmode` argument of `haver.data`. If this argument is not supplied, `aggmode` always defaults to ‘strict’. This is independent of what you set using `dlxSetAggregation`.

The behavior of `dlxGetData` is different: Here settings invoked by `dlxSetAggregation` really determine under which aggregation mode data are queried.

For a description of aggregation modes, see `haver.data`.

#### Using Aliases for Haver Series Codes

In `dlxGetData`, you can supply an argument `.colnames` that renames Haver series to names of your liking. `haver.data` does not have a corresponding argument. Instead, the renaming feature has been expanded for `HaverMetaData` and `HaverData` objects. You can incrementally apply Haver code aliases of your liking, and you can reset names to the original Haver codes. The mapping of original Haver series codes and your aliases is always stored in the objects and can be extracted at any time.

#### Starting and Ending Dates of Queries

In `dlxGetdata`, arguments ‘start’ and ‘end’ could be supplied as different objects (character strings, R Date objects, `chron` objects, etc.). In `haver.data`, these arguments must be R Date objects.

### Author(s)

Haver Analytics <tech@haver.com>

Maintainer: Haver Analytics <tech@haver.com>

### See Also

See Haver_package for all help entries related to the Haver package.

[Package Haver version 3.2 Index]