Package 'readrba'

Title: Download and Tidy Data from the Reserve Bank of Australia
Description: Download up-to-date data from the Reserve Bank of Australia in a tidy data frame. Package includes functions to download current and historical statistical tables (<https://www.rba.gov.au/statistics/tables/>) and forecasts (<https://www.rba.gov.au/publications/smp/forecasts-archive.html>). Data includes a broad range of Australian macroeconomic and financial time series.
Authors: Matt Cowgill [aut, cre] , Angus Moore [ctb]
Maintainer: Matt Cowgill <[email protected]>
License: MIT + file LICENSE
Version: 0.1.11.900
Built: 2024-11-16 22:21:41 UTC
Source: https://github.com/mattcowgill/readrba

Help Index


Browse available RBA data series

Description

Use these functions to find the table number or series ID of the data you're interested in.

Usage

browse_rba_series(search_string = "")

browse_rba_tables(search_string = "", refresh = FALSE)

Arguments

search_string

Word or phrase to search for, such as "gold" or "commodity" or "labour". If left as "", the function will return all series.

refresh

logical; FALSE by default. When FALSE, internal data is used. When TRUE, the RBA website is re-scraped to obtain current information about available tables This can take a few seconds.

Value

A data.frame (tbl_df) containing RBA data series/tables that match the search_string. Where no search_string is supplied, the data.frame will contain information about all RBA series/tables.

The data.frame returned by browse_rba_tables() includes a column called readable. This column takes the value TRUE if the table is able to be read by read_rba() and FALSE if it cannot be read.

Examples

# Find series that contain 'unemployment'
browse_rba_series("unemployment")

# Or all labour-related series
browse_rba_series("labour")

# Or those related to commodities
browse_rba_series("commodities")

# Or all series
browse_rba_series()

# Or just look for tables that contain the word 'labour'
browse_rba_tables("labour")

# Or all tables
browse_rba_tables()

# To re-scrape the RBA website to ensure you have up-to-date information
# about available tables:
## Not run: 
browse_rba_tables(refresh = TRUE)

## End(Not run)

Compile the RBA's public forecasts of key economic variables over time

Description

Compile the RBA's public forecasts of key economic variables over time

Usage

rba_forecasts(
  refresh = TRUE,
  all_or_latest = c("all", "latest"),
  remove_old = TRUE
)

read_forecasts(...)

Arguments

refresh

logical; default is TRUE. When set to TRUE, up-to-date forecasts will be downloaded from the RBA's website. When FALSE, only the package's internal data will be returned, which may be out of date.

all_or_latest

character; default is "all". When "all" is specified, all publicly-available forecasts will be returned; when "latest", only the latest forecasts will be used.

remove_old

logical; default is TRUE. When TRUE, any observations for which the date is more than 180 days prior to the forecast_date is excluded.

...

Arguments passed to rba_forecasts()

Details

Forecasts are not available for all series on all forecast dates. CPI inflation and GDP growth are included in all forecasts. The unemployment rate is included in most forecasts. Other series are included inconsistently, based on their availability in the underlying source data.

All forecasts issued on or before November 2014 come from Tulip and Wallace (2012), RBA RDP2012-07. Data available: https://www.rba.gov.au/statistics/historical-forecasts.html.

Data from 2015 to August 2018 are scraped from the RBA's quarterly Statement on Monetary Policy (https://www.rba.gov.au/publications/smp/2020/aug/). Note from from Feb 2015 to August 2018 (inclusive) only include a few series; those from November 2018 onwards include more series.

Data from November 2018 to present comes from the published 'Forecasts Archive' file on the RBA website (https://www.rba.gov.au/publications/smp/forecasts-archive.html).

read_forecasts() is a wrapper around rba_forecasts().

Value

A tidy tbl_df containing 8 columns:

forecast_date

The (approximate) date on which the forecast was published. Note that this is the first day of the publication month, so the forecast_date for forecasts in the February 2020 Statement on Monetary Policy is as.Date("2020-02-01").

date

The date to which the forecast pertains. Note that this is the first day of the final month of the relevant quarter. For example, a forecast of GDP in the June quarter 2021 will be as.Date("2021-06-01").

year_qtr

The year and quarter to which the forecast pertains, such as 2019.1.

series

Short, snake_case description of the data series being forecast, such as gdp_change or unemp_rate. These are consistent over time.

value

The forecast value, in per cent. For example, if GDP growth is forecast to be 3 per cent, the value will be 3. Note that where a forecast is given as a range (eg. 3.5-4.5%) the value will be the midpoint of the range (eg. 4%).

series_desc

Full description of the series being forecast, as per the RBA website, such as "Real household disposable income". Note that series descriptions are not necessarily consistent over time; the values here are those published by the RBA. The series column is consistent over time.

source

For recent forecasts, this is 'SMP', meaning the RBA's Statement on Monetary Policy. Forecasts prior to 2014 are sourced from various places; see Details.

notes

Notes accompanying the forecasts, as per the RBA's website. Note these are identical for item in a given forecast_date.

Examples

forecasts <- read_forecasts()

Convenience function to get the RBA's cash rate.

Description

Convenience function to get the RBA's cash rate.

Usage

read_cashrate(type = c("target", "interbank", "both"))

rba_cashrate(...)

Arguments

type

One of 'target' (the default), 'interbank', or 'both'.

'target'

The RBA's cash rate target.

'interbank'

The interbank overnight cash rate.

'both'

Both the cash rate target and interbank overnight cash rate.

'target' fetches the RBA cash rate target. 'interbank'

...

arguments passed to read_cashrate()

Details

Note that in the very early 1990s, the cash rate target was expressed as a range (eg. "17% to 17.5%"). Where this is the case, the value returned here (and in read_rba()) is the mid-point of this range.

If type = 'both', note that the returned tbl is tidy/long.

rba_cashrate() is a wrapper around read_cashrate().

Value

A tbl_df with two columns: date and cash_rate.


Download, import, and tidy statistical tables from the RBA

Description

Download, import, and tidy statistical tables from the RBA

Usage

read_rba(
  table_no = NULL,
  cur_hist = "current",
  series_id = NULL,
  path = tempdir(),
  update_urls = FALSE
)

read_rba_seriesid(series_id, path = tempdir())

Arguments

table_no

Character vector of table number(s), such as "A1" or c("a1.1", "g1").

cur_hist

Character; valid values are "current" or "historical".

series_id

Optional, character. Specifying series_id is an alternative to specifying table_no.

Supply unique RBA time series identifier(s). For example, "GCPIAG" is the identifier for the CPI, so series_id = "GCPIAG" will return this series. You can supply multiple series IDs as a character vector, such as series_id = c("GCPIAG", "GCPIAGSAQP").

Note that cur_hist is ignored if you specify series_id - both current and historical data will be included in the output.

path

Directory in which to save downloaded RBA Excel file(s). Default is tempdir().

update_urls

Logical; default is FALSE. When FALSE, an internal table is used to fetch the URL(s) corresponding to the requested data. If TRUE, the RBA website is scraped to obtain updated URL(s).

Must be either a vector of either length 1 (eg. "cur_hist = "current") or the same length as table_no (eg. cur_hist = c("current", "historical")).

cur_hist is ignored if series_id is specified.

Details

read_rba() downloads, imports and tidies data from statistical tables published by the Reserve Bank of Australia. You can specify the requested data using the table_no or series_id.

To find the table_no or series_id that corresponds to the data you want, use the functions browse_rba_tables() and/or browse_rba_series(). Note that some historical exchange rate tables do not have table numbers on the RBA website; they have been assigned table numbers - see ⁠browse_rba_tables("exchange rates").⁠

To see which tables cannot currently be read, run browse_rba_tables(FALSE).

read_rba_seriesid() is a wrapper around read_rba().

Certain corporate networks restrict your ability to download files in an R session. On some of these networks, the "wininet" method must be used when downloading files. Users can specify the method that will be used to download files by setting the "R_READRBA_DL_METHOD" environment variable.

For example, the following code sets the environment variable for your current session: Sys.setenv("R_READRBA_DL_METHOD" = "wininet") You can add "R_READRBA_DL_METHOD" to your .Rprofile to have this persist across sessions.

Value

A single tidy tibble containing the requested table(s)

Examples

## Not run: 
# Get a single table:
read_rba(table_no = "a1.1")

# Get multiple tables, combined in a tidy tibble:
read_rba(table_no = c("a1.1", "g1"))

# Get both the current and historical versions of a table
read_rba(table_no = c("a1.1", "a1.1"), cur_hist = c("current", "historical"))

# Get data based on the series ID:
read_rba(series_id = "GCPIAG")

# Or, equivalently, use:
read_rba_seriesid("GCPIAG")

# Get multiple series IDs:
read_rba(series_id = c("GCPIAG", "GCPIAGSAQP"))

## End(Not run)

Load and tidy local RBA Excel sheets

Description

Load and tidy local RBA Excel sheets

Usage

read_rba_local(filenames, series_id = NULL)

Arguments

filenames

Vector of filename(s) (with path) pointing to local RBA Excel sheets

series_id

Optional series ID

Value

A tbl_df containing tidied RBA Excel sheet(s)

Examples

## Not run: 
read_rba_local("data/rba_file.xls")

## End(Not run)

Tidy a statistical table from the RBA

Description

Tidy a statistical table from the RBA

Usage

tidy_rba(excel_sheet, series_id = NULL)

Arguments

excel_sheet

Dataframe of RBA spreadsheet.

series_id

Optional series ID

Value

Tidy tibble