Skip to contents

The data is cached for the duration of the current R session. A series group that cannot be read is reported as a warning and comes back as a row holding only its group_name, so that a call spanning many groups is not lost to one bad group.

Usage

get_boc_series_group(
  series_group,
  start_date = NULL,
  end_date = NULL,
  recent = NULL,
  recent_weeks = NULL,
  recent_months = NULL,
  recent_years = NULL,
  order_dir = NULL,
  quarter_convention = getOption("canbank.quarter_convention", "middle"),
  quiet = FALSE,
  refresh = FALSE
)

Arguments

series_group

A vector of series group identifiers

start_date

(Optional) Start date for time series

end_date

(Optional) End date for time series

recent

(Optional) Only retrieve most recent recent number of data points

recent_weeks

(Optional) Only retrieve data for most recent recent_weeks weeks

recent_months

(Optional) Only retrieve data for most recent recent_months months

recent_years

(Optional) Only retrieve data for most recent recent_years years

order_dir

(Optional) Order observations by dimension, either "asc" or "desc"

quarter_convention

(Optional) Which day to use for observations the API reports as a quarter rather than a date, for example "1998Q3". One of "middle" (the default, mapping Q1 to February 1, Q2 to May 1, Q3 to August 1 and Q4 to November 1), "start" (the first day of the quarter) or "end" (the last day of the quarter). Observations the API reports as a date are used as reported and are unaffected by this. Defaults to getOption("canbank.quarter_convention", "middle").

quiet

(Optional) Don't emit messages or warnings if TRUE, default is FALSE

refresh

(Optional) Refresh currently cached series if TRUE, default is FALSE

Value

a tibble with series data. value holds the observation as the API reports it and Value its numeric coercion; Value is omitted when no observation in the result is numeric, as for the auction series that hold ISINs, maturity codes or clock times. NULL if the API could not be reached.

Details

Returns NULL, with a warning, if the Bank of Canada API cannot be reached or refuses the request.

Examples

# \donttest{
get_boc_series_group("FX_RATES_ANNUAL", recent_years = 5)
#> Downloading BOC series group data for FX_RATES_ANNUAL
#> # A tibble: 92 × 9
#>    group_name      dimension dimension_value Date       series label description
#>    <chr>           <chr>     <chr>           <date>     <chr>  <chr> <chr>      
#>  1 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXANO… NOK/… Annual ave…
#>  2 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXATR… TRY/… Annual ave…
#>  3 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXAIN… INR/… Annual ave…
#>  4 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXATW… TWD/… Annual ave…
#>  5 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXAID… IDR/… Annual ave…
#>  6 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXACH… CHF/… Annual ave…
#>  7 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXAMX… MXN/… Annual ave…
#>  8 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXASE… SEK/… Annual ave…
#>  9 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXANZ… NZD/… Annual ave…
#> 10 FX_RATES_ANNUAL Date      2022-01-01      2022-01-01 FXAJP… JPY/… Annual ave…
#> # ℹ 82 more rows
#> # ℹ 2 more variables: value <chr>, Value <dbl>
# }