Download, import, and tidy statistical tables from the RBA

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.

Value

A single tidy tibble containing the requested table(s)

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.

Examples

if (FALSE) { # \dontrun{
# 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"))
} # }