getSeries {bundesbank}R Documentation

Download Time-Series Data from Bundesbank

Description

Download time-series from the website of the Bundesbank.

Usage

getSeries(series,
          start = NULL,
          end = format(Sys.Date(), "%Y-%m"),
          return.class = "data.frame",
          verbose = TRUE, dest.dir = NULL,
          column1.only = TRUE)

Arguments

series

The series name as given by the Bundesbank (e.g. ‘BBK01.ST0316’ for 3-Month EURIBOR).

start

character in format ‘YYYY-MM’ or ‘YYYY’. If omitted, the function downloads data from the earliest available date. Currently ignored for real-time datasets.

end

character in format ‘YYYY.MM’ or ‘YYYY’. If omitted, the function downloads data up to the most recent available date. Currently ignored for real-time datasets.

return.class

character or NULL. Currently supported are "zoo" and "data.frame". If NULL or "list", a list is returned for time-series. Real-time data are always returned as a data.frame.

verbose

logical

dest.dir

NULL or character. If character, it must be the path to an existing directory. See Details.

column1.only

logical, and default is TRUE, which is required for return.class zoo. If FALSE, additional columns are kept; such columns typically contain comments and notes.

Details

The data can be downloaded in CSV-format from the Bundesbank's website https://www.bundesbank.de/en/statistics/time-series-databases .

If dest.dir is provided, the downloaded dataset gets a date prefix (today in format YYYYMMDD) and is stored in directory dest.dir. Before any download is attempted, the function checks whether a file with today's prefix exist in dest.dir; if yes, the file is used.

Value

A data.frame with two (or more) columns:

dates

dates (of class Date)

values

numerical values

The result for single time-series may have an attribute info, which is a character vector and holds additional information for series (such as its unit). See Examples.

Real-time datasets are always organised as a data.frame, in which the rows correspond to the reporting period and the columns to the publication date. Real-time datasets always have several attributes, in particular date, which corresponds to the publication date.

If a download files, the function will print the error message, but evaluate to NULL (invisibly).

Author(s)

Maintainer: Enrico Schumann <es@enricoschumann.net>

Examples


## (Internet connection required)

series <- "BBK01.ST0304" ## Eonia
res <- getSeries(series) ## retrieve all available data
res <- getSeries(series, start = "2012-01")
res <- getSeries(series, end   = "2012-01")
res <- getSeries(series, start = "2012-01", end = "2012-05")

## If the download fails, 'res' will be NULL.
## This typically happens when the website of the
## Bundesbank is not available.

if (!is.null(res)) {

    ## make 'zoo' series
    if (require("zoo")) {
        Eonia <- zoo(res$values, res$dates)
        plot(Eonia)
    }

    ## check comments
    writeLines(strwrap(paste("- ", attr(res, "info")),
               width = 60, exdent = 2))

    ## real-time dataset (Gross domestic product)
    gdp <- getSeries("BBKRT.A.DE.N.A.AG1.CA010.V.A")

    ## use caching
    ## ==> the example uses a temporary directory, but
    ##     better is to use a less ephemeral destination,
    ##     e.g. '~/Downloads/bundesbank'
    gdp <- getSeries("BBKRT.A.DE.N.A.AG1.CA010.V.A",
                     dest.dir = tempdir())
    ### Downloading data from Bundesbank ... Done.

    gdp <- getSeries("BBKRT.A.DE.N.A.AG1.CA010.V.A",
                     dest.dir = tempdir())
    ### Using cache ... Done.
}


[Package bundesbank version 0.1-12 Index]