Title: Download Data from the Reserve Bank of New Zealand Website
Version: 1.1.0
Description: Provides a convenient way of accessing data published by the Reserve Bank of New Zealand (RBNZ) on their website, https://www.rbnz.govt.nz/statistics. A range of financial and economic data is provided in spreadsheet format including exchange and interest rates, commercial lending statistics, Reserve Bank market operations, financial institution statistics, household financial data, New Zealand debt security information, and economic indicators. This package provides a method to download those spreadsheets and read them directly into R.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
Depends: R (≥ 3.5.0)
Imports: httr, lubridate, readxl, rvest, xml2
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
BugReports: https://github.com/rntq472/RBNZ/issues
NeedsCompilation: no
Packaged: 2020-07-27 10:14:53 UTC; jasper
Author: Jasper Watson [aut, cre]
Maintainer: Jasper Watson <jasper.g.watson@gmail.com>
Repository: CRAN
Date/Publication: 2020-07-27 23:20:03 UTC

Exchange Rates and TWI

Description

See https://www.rbnz.govt.nz/statistics/b1 for a full description.

Arguments

option

Allowed values are “daily” (default) and “monthly”.

Note

The historical data is split across multiple files at source. We download all of them and merge together to form a complete history.


TWI Weights

Description

See https://www.rbnz.govt.nz/statistics/b10 for a full description.


Historical TWI Weights

Description

See https://www.rbnz.govt.nz/statistics/b13 for a full description.

Note

The historical data is split across multiple files at source. We download all of them and merge together into a single data frame, but note that unlike with most of the other series available here it is not a simple matter of rbind-ing all the data together. The composition of the TWI changed in December 2014 but there were some components that were present both before and after, for example Australia. These are returned as separate fields in the output rather than combining them into a single entry.


Wholesale Interest Rates

Description

See https://www.rbnz.govt.nz/statistics/b2 for a full description.

Arguments

option

Allowed values are “daily” (default), “dailyclose”, “monthly”, and “monthlyclose”.

Note

The historical data is split across multiple files at source. We download all of them and merge together to form a complete history.


New Residential Mortgage Standard Interest Rates

Description

See https://www.rbnz.govt.nz/statistics/b20-new-customer-average-rate for a full description.


New Residential Mortgage Special Interest Rates

Description

See https://www.rbnz.govt.nz/statistics/b21-new-residential-mortgage-special-interest-rates for a full description.


New Interest Bearing Call Savings Account Interest Rates

Description

See https://www.rbnz.govt.nz/statistics/b25-new-interest-bearing-call-savings-account-interest-rates for a full description.


New Interest Bearing Term Deposit Interest rates

Description

See https://www.rbnz.govt.nz/statistics/b26-new-interest-bearing-term-deposit-interest-rates for a full description.


New Interest Bearing Term PIE Deposits Interest Rates

Description

See https://www.rbnz.govt.nz/statistics/b27-new-interest-bearing-term-pie-deposits-interest-rates for a full description.


Retail Interest Rates on Lending and Deposits

Description

See https://www.rbnz.govt.nz/statistics/b3 for a full description.


Foreign Exchange Turnover

Description

See https://www.rbnz.govt.nz/statistics/b4 for a full description.

Arguments

option

Allowed values are “NZD” (default), “USD” and “EUR”.


Yields on Loans

Description

See https://www.rbnz.govt.nz/statistics/b6-yields-on-loans for a full description.


Credit Card Balances

Description

See https://www.rbnz.govt.nz/statistics/c12 for a full description.

Arguments

option

Allowed values are “monthend” (default) and “dailyaverage”.


Credit Card Spending

Description

See https://www.rbnz.govt.nz/statistics/c13 for a full description.

Arguments

option

Allowed values are “issued” (default) and “used”.


Key Household Financial Statistics

Description

See https://www.rbnz.govt.nz/statistics/c21 for a full description.


Household Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/c22 for a full description.


New Residential Mortgage Lending by Loan-To-Valuation Ratio

Description

See https://www.rbnz.govt.nz/statistics/c30 for a full description.

Arguments

option

Allowed values are “default” (default) and “longrun”.

Note

There are a few other files present on the webpage for this series but they are not downloaded. You will need to retrieve them manually if you want them.


New Residential Mortgage Lending by Borrower Type

Description

See https://www.rbnz.govt.nz/statistics/c31 for a full description.


New and Existing Residential Mortgage Lending by Payment Type

Description

See https://www.rbnz.govt.nz/statistics/c32 for a full description.


Residential Mortgage Loan Reconciliation

Description

See https://www.rbnz.govt.nz/statistics/c35 for a full description.


Residential Mortgage Lending by Debt-To-Income Purpose Use

Description

See https://www.rbnz.govt.nz/statistics/c40-residential-mortgage-lending-by-debt-to-income-dti-purpose-use for a full description.


Residential Mortgage Borrower Gross Income (BGI)

Description

See https://www.rbnz.govt.nz/statistics/c41-residential-mortgage-borrower-gross-income-bgi for a full description.


Sector Lending

Description

See https://www.rbnz.govt.nz/statistics/c5 for a full description.


Money and Credit Aggregates (Depository Corporations)

Description

See https://www.rbnz.govt.nz/statistics/c50-money-and-credit-aggregates for a full description.

Arguments

option

Allowed values are “default” (default) and “longrun”.


Other Depository Corporations Analytical Accounts

Description

See https://www.rbnz.govt.nz/statistics/c51-other-depository-corporations-analytical-accounts for a full description.


Depository Corporations Analytical Accounts

Description

See https://www.rbnz.govt.nz/statistics/c52-depository-corporations-analytical-accounts for a full description.


Other Financial Corporations Analytical Accounts

Description

See https://www.rbnz.govt.nz/statistics/c55-other-financial-corporations-analytical-accounts for a full description.


Credit Conditions Survey

Description

See https://www.rbnz.govt.nz/statistics/c60-credit-conditions-survey for a full description.

Note

There is a second dataset present (the ec60 file) which is not retrieved as it is in a non-standard format.


Bank Customer Lending Flows

Description

See https://www.rbnz.govt.nz/statistics/c65-bank-customer-lending-flows for a full description.


Bank Customer Lending Stocks

Description

See https://www.rbnz.govt.nz/statistics/c66-bank-customer-lending-stocks for a full description.


Influences on Settlement Cash

Description

See https://www.rbnz.govt.nz/statistics/d10 for a full description.

Note

This data is in a non-standard format.


Standing Facilities

Description

See https://www.rbnz.govt.nz/statistics/d12 for a full description.

Note

This data is in a non-standard format.


Open Market Operations

Description

See https://www.rbnz.govt.nz/statistics/d3 for a full description.

Note

This data is in a non-standard format.


Holdings of Central Government Debt Securities

Description

See https://www.rbnz.govt.nz/statistics/d30 for a full description.


Non-Resident Holdings of Individual Bonds (Nominal Value)

Description

See https://www.rbnz.govt.nz/statistics/d31 for a full description.


Holdings of Kauri Bonds (Nominal Value)

Description

See https://www.rbnz.govt.nz/statistics/d35 for a full description.


Government Bond Turnover

Description

See https://www.rbnz.govt.nz/statistics/d9 for a full description.

Arguments

option

Allowed values are “daily” (default) and “monthly”.


New Zealand's Official Overseas Reserves

Description

See https://www.rbnz.govt.nz/statistics/e1 for a full description.


New Zealand's Position with the IMF

Description

See https://www.rbnz.govt.nz/statistics/e2 for a full description.


Bank Notes in the Hands of the Public

Description

See https://www.rbnz.govt.nz/statistics/f3 for a full description.

Note

This data is in a non-standard format.


Coin Mintings

Description

See https://www.rbnz.govt.nz/statistics/f4 for a full description.

Note

This data is in a non-standard format.


Reserve Bank Foreign Currency Assets and Liabilities

Description

See https://www.rbnz.govt.nz/statistics/f5 for a full description.

Note

This data is in a non-standard format.


Insurance: Income Statement

Description

See https://www.rbnz.govt.nz/statistics/j10-insurance-income-statement for a full description.


Insurance: Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/j20-insurance-balance-sheet for a full description.


Mismatch Ratios

Description

See https://www.rbnz.govt.nz/statistics/l1 for a full description.


Core Funding Ratio

Description

See https://www.rbnz.govt.nz/statistics/l2 for a full description.


Face Value of Funding by Residual Maturity ($m)

Description

See https://www.rbnz.govt.nz/statistics/l3 for a full description.


Prices

Description

See https://www.rbnz.govt.nz/statistics/m1 for a full description.

Arguments

option

Allowed values are “default” (default) and “longrun”.


Housing

Description

See https://www.rbnz.govt.nz/statistics/m10 for a full description.


Population and Migration

Description

See https://www.rbnz.govt.nz/statistics/m12 for a full description.


Household Inflation Expectations

Description

See https://www.rbnz.govt.nz/statistics/m13 for a full description.


Survey of Expectations

Description

See https://www.rbnz.govt.nz/statistics/m14 for a full description.


Consumption

Description

See https://www.rbnz.govt.nz/statistics/m2 for a full description.


Investment

Description

See https://www.rbnz.govt.nz/statistics/m3 for a full description.


Domestic Trade

Description

See https://www.rbnz.govt.nz/statistics/m4 for a full description.


Gross Domestic Product

Description

See https://www.rbnz.govt.nz/statistics/m5 for a full description.


National Saving (Year Ended March)

Description

See https://www.rbnz.govt.nz/statistics/m6 for a full description.


Balance of Payments and International Investment Position

Description

See https://www.rbnz.govt.nz/statistics/m7 for a full description.


Overseas Trade

Description

See https://www.rbnz.govt.nz/statistics/m8 for a full description.


Labour Market

Description

See https://www.rbnz.govt.nz/statistics/m9 for a full description.


Reserve Bank Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/r1 for a full description.


Reserve Bank Statistical Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/r2 for a full description.


Reserve Bank Analytical Accounts

Description

See https://www.rbnz.govt.nz/statistics/r3 for a full description.


Access Data from the Reserve Bank of New Zealand Website

Description

Provides a convenient way of accessing data published by the Reserve Bank of New Zealand (RBNZ) on their website, <https://www.rbnz.govt.nz/statistics>. A range of financial and economic data is provided in spreadsheet format including exchange and interest rates, commercial lending statistics, Reserve Bank market operations, financial institution statistics, household financial data, New Zealand debt security information, and economic indicators. This package provides a method to download those spreadsheets and read them directly into R.

Details

The copyright notice for this data can be found at https://www.rbnz.govt.nz/copyright.

Author(s)

Jasper Watson


Banks: Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/s10-banks-balance-sheet for a full description.

Arguments

option

Allowed values are “default” (default) and “moredetail”.


Banks: Summary Income Statement and Related Ratios

Description

See https://www.rbnz.govt.nz/statistics/s20 for a full description.


Banks: Income Statement

Description

See https://www.rbnz.govt.nz/statistics/s21 for a full description.


Banks: Assets - Loans by Sector

Description

See https://www.rbnz.govt.nz/statistics/s30-banks-assets-loans-by-sector for a full description.


Banks: Assets – Loans by Purpose

Description

See https://www.rbnz.govt.nz/statistics/s31-banks-assets-loans-by-purpose for a full description.


Banks: Assets – Loans by Product

Description

See https://www.rbnz.govt.nz/statistics/s32-banks-assets-loans-by-product for a full description.


Banks: Assets – Loans Fully Secured by Residential Mortgage

Description

See https://www.rbnz.govt.nz/statistics/s33-banks-assets-loans-fully-secured-by-residential-mortgage-by-repricing for a full description.

Arguments

option

Allowed values are “default” (default) and “longrun”.


Banks: Assets – Loans and Repos by Industry

Description

See https://www.rbnz.govt.nz/statistics/s34-banks-assets-loans-by-industry for a full description.


Banks: Liabilities – Deposits by Sector

Description

See https://www.rbnz.govt.nz/statistics/s40-banks-liabilities-deposits-by-sector for a full description.

Arguments

option

Allowed values are “default” (default) and “longrun”.


Banks: Liabilities – Deposits by Industry

Description

See https://www.rbnz.govt.nz/statistics/s41-banks-liabilities-deposits-by-industry for a full description.


NZ's International Reserves and Foreign Currency Liquidity

Description

See https://www.rbnz.govt.nz/statistics/sdds for a full description.

Arguments

option

Allowed values are “current” (default) and a year and month specified in the form “20nn-nn”.

Note

This is a non-standard dataset.


Non Banks: Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/t1 for a full description.


Savings Institutions: Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/t11 for a full description.


Deposit Taking Finance Companies: Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/t21 for a full description.


Non-Deposit Taking Finance Companies: Balance Sheet

Description

See https://www.rbnz.govt.nz/statistics/t31 for a full description.


Non Banks: Funding and Claims by Sector

Description

See https://www.rbnz.govt.nz/statistics/t4 for a full description.


Funds Under Management

Description

See https://www.rbnz.govt.nz/statistics/t40 for a full description.


Managed Fund Assets

Description

See https://www.rbnz.govt.nz/statistics/t41 for a full description.


Life Insurance

Description

See https://www.rbnz.govt.nz/statistics/t42 for a full description.


KiwiSaver

Description

See https://www.rbnz.govt.nz/statistics/t43 for a full description.


Other Registered Superannuation

Description

See https://www.rbnz.govt.nz/statistics/t44 for a full description.


Retail Unit Trusts

Description

See https://www.rbnz.govt.nz/statistics/t45 for a full description.


Cash Management Trusts

Description

See https://www.rbnz.govt.nz/statistics/t46 for a full description.


Wholesale Trusts

Description

See https://www.rbnz.govt.nz/statistics/t47 for a full description.


Wholesale Trusts and Other Funds

Description

See https://www.rbnz.govt.nz/statistics/t48 for a full description.


List All Data Series Available for Download

Description

List All Data Series Available for Download

Usage

allAvailableSeries()

Value

Character vector of series names.

Author(s)

Jasper Watson

Examples


print(allAvailableSeries())


Description

Determine the URL for a File to be Downloaded

Usage

getDownloadLink(subFileName, seriesPage, series)

Arguments

subFileName

The name of the file to be downloaded, as provided by seriesOptions(). May contain only part of a series.

seriesPage

An XML document returned by xml2::read_html containing the webpage pertaining to the desired series.

series

Character string giving the name of the data series to retrieve.

Value

Character string giving the URL of the file to be downloaded.

Author(s)

Jasper Watson


Retrieve Data From the Reserve Bank of New Zealand Website

Description

Retrieves data from https://www.rbnz.govt.nz/statistics for the series specified by the user. This involves downloading one or more spreadsheets and reading them into R.

Usage

getSeries(
  series,
  option = getDefaultOption(series),
  replaceColumnNames = TRUE,
  fieldForColumnNames = "Series",
  destDir,
  quiet = TRUE
)

Arguments

series

Character string giving the name of the data series to retrieve.

option

Character string specifying which format of the data series to retrieve, if necessary. For information on the available options see the help file for the particular series name (for example ?B1 will tell you that the B1 series can be downloaded either as daily or monthly data, with the former being the default). This argument is unnecessary for series that only have one data format.

replaceColumnNames

Logical indicating whether to change the column names of the output data from the Series ID's used in the source spreadsheets to more informative values based on the information in the metadata. Defaults to TRUE.

fieldForColumnNames

If replaceColumnNames is TRUE then this variable specifies which columns of the meta data file will be used to construct the column names. Defaults to “Series” but sometimes you may want to change it to “Group” or c(“Group”, “Series”). “SeriesID” is also allowed.

destDir

File path to a directory in which to place the downloaded spreadsheets. If not specified they will be placed into tempdir() and deleted on exit.

quiet

Logical to be passed to utils::download.file.

Value

For most series a list containing the fields “meta” and “data” which are data frames containing the metadata and actual data, respectively. There are a few series that do not follow this format, and for these the spreadsheets are just downloaded and read into a list of data frames, one for each sheet, with no organising or cleaning.

Author(s)

Jasper Watson

Examples


## List the available data series.
print(allAvailableSeries())

## Not run: 

## Download exchange rate data and plot NZD vs sterling.
b1 <- getSeries('B1')
plot(b1$data$Date, b1$data$UK_pound_sterling, type = 'l')

## Now use monthly data (previous was daily).
b1_monthly <- getSeries('B1', 'monthly')
plot(b1_monthly$data$Date, b1_monthly$data$UK_pound_sterling,
     type = 'l')


## End(Not run)

Determine the URL of a Webpage Pertaining to a Series

Description

Determine the URL of a Webpage Pertaining to a Series

Usage

getSeriesPageURL(series)

Arguments

series

Character string giving the name of the data series to retrieve.

Value

Character string giving the URL of the series webpage.

Author(s)

Jasper Watson


Read a Series Webpage Into an XML object

Description

Read a Series Webpage Into an XML object

Usage

readSeriesPage(series, quiet = TRUE)

Arguments

series

Character string giving the name of the data series to retrieve.

quiet

Logical to be passed to utils::download.file.

Value

An XML document returned by xml2::read_html containing the webpage pertaining to the desired series.

Author(s)

Jasper Watson


Read a Downloaded Spreadsheet

Description

Read a Downloaded Spreadsheet

Usage

readSpreadsheet(
  destfile,
  series,
  subFileName,
  fieldForColumnNames,
  deleteFiles
)

Arguments

destfile

File path of the downloaded spreadsheet.

series

Character string giving the name of the data series to retrieve.

subFileName

Name of the spreadsheet for download according to the source URL.

fieldForColumnNames

If replaceColumnNames is TRUE then this variable specifies which columns of the meta data file will be used to construct the column names. Defaults to “Series” but sometimes you may want to change it to “Group” or c(“Group”, “Series”). “SeriesID” is also allowed.

deleteFiles

Logical indicating whether to delete the spreadsheet after reading it.

Value

The contents of the spreadsheet. For most series this will be in the form of a list of two data frames, one called “data” and the other “meta”. For some series (see specialCases()), the data is not in the standard format as the rest and so is just returned directly as the results of read_xlsx for each sheet in the spreadsheet.

Note

Series B13 doesn't have a full date specified, only year or month and year. These values values are returned as the first of the month/year.

Author(s)

Jasper Watson

mirror server hosted at Truenetwork, Russian Federation.