HaverData {Haver} | R Documentation

## HaverData Object

### Description

A HaverData object is the default return type of `haver.data`. It contains times series data queried from Haver Analytics databases.

If you have not done so yet, have a look at `haver.data` before reading this help entry.

### Usage

    ## S3 method for class 'HaverData'
    print(x, data=TRUE)
    ## S3 method for class 'HaverData'
    as.matrix(x)
    ## S3 method for class 'HaverData'
    as.data.frame(x)
    ## S3 method for class 'HaverData'
    as.ts(x)

    haver.as.zoo(x)

### Arguments

`x` | a `HaverData` object
`data` | a logical `TRUE` / `FALSE`. If `data=FALSE`, only summary information on the data set will be printed.

### Details

The `print` method by default displays time series data as well as some data set properties. If you are only interested in the data set properties and if you want to suppress lengthy data output, use option `data=FALSE`.

If you need to index into the `HaverData` object, we recommend that you first convert it to a a matrix using `as.matrix`. If you index directly into a `HaverData` object, the returned object will be a matrix, not a `HaverData` object.

Indexing replacement operations (`"[<-"`) are not allowed.

`as.matrix`, `as.data.frame`, `as.ts`, and `haver.as.zoo` are coercion functions. Note that the conversion function to `zoo` objects starts with `haver`.

The time sequence vector will never have gaps, which implies that missing values of time series are always explicitly shown as NAs.

The metadata for all time series of a `HaverData` object are stored as a `HaverMetaData` object within the `HaverData` object. `haver.datamd` returns a copy of this object.

The `HaverData` object contains information on lists of series codes that have been successfully retrieved and on codes that were dropped from the query. You can use `haver.codelists` to extract these code lists.

You can assign aliases to Haver codes of the `HaverData` object if you prefer to use your own series names in your analysis. Use `haver.setalias` to do this.

### Value

`print` prints the time series data and returns the `HaverData` object (invisibly).

`[.HaverData` returns a matrix, not a `HaverData` object.

`as.matrix`, `as.data.frame`, `as.ts`, and `haver.as.zoo` return the type indicated in the function name.

### Coercion to Other Types

The purpose of existence of the `HaverData` object is to hold data from Haver Analytics databases. It is not designed for data analysis. With `HaverData` objects you cannot

- delete time periods

- add/prepend/append time periods

- delete or add time series

- reorder time series

- merge two or more `HaverData` objects

- plot time series

For the above operations, you either have to re-run the query using `haver.data` or you have to coerce the `HaverData` object to something else and perform the desired operation on that object. The Haver package offers coercion functions to four other R types.

Be aware that when using these coercion functions, the metadata does not get copied into the new objects. It is therefore recommended to generate an object in addition to the `HaverData` object, as in
`> hd <- haver.data(codes="haverd:fxrwb")`
`> ex_ts <- as.ts(hd)`
instead of just
`> ex_ts <- haver.data(codes="haverd:fxrwb", rtype="ts")`

With the former approach, the data and metadata that you are using in your analysis are much more tractable.

### See Also

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

### Examples

    haver.path()
    haver.path("examples")

    ## In the 'Examples' section of 'haver.data' we saw instances where series were
    ## dropped because temporal aggregation or disaggregation could not be performed:
    hmd_mqa <- haver.metadata(database="havermqa")
    hd_mqa1 <- haver.data(hmd_mqa)
    hd_mqa2 <- haver.data(codes=hmd_mqa, freq="q")

    ## To determine which codes have been successfully queried and which ones
    ## got dropped, you can use the 'haver.codelists' function:
    haver.codelists(hd_mqa1)
    haver.codelists(hd_mqa2)

    ## Both 'hd_mqa1' and 'hd_mqa2' contain a lot of data so their contents is
    ## better looked at using 'View' rather than 'print'.
    ## If you want to just print summary information on the data set but
    ## suppress the display of time series data points, use the 'data' argument:
    print(hd_mqa1, data=FALSE)
    print(hd_mqa2, data=FALSE)

    ## If you need to index into the 'HaverData' object, it is safer to convert it
    ## to a matrix first:
    ex_mat  <- as.matrix(hd_mqa1)
    ex_mat2 <- ex_mat[67:77, c("c","cd")]
    ex_mat2

    haver.path("restore")

[Package Haver version 3.2 Index]