Skip to contents

Pulls the same EFO table from two vintages and returns a tidy diff with a revision column (value_b - value_a). Useful for quantifying how the OBR's view changed between fiscal events.

Usage

obr_compare_vintages(vintage_a, vintage_b, what = "fiscal", refresh = FALSE)

Arguments

vintage_a, vintage_b

EFO vintage labels (e.g. "October 2024", "March 2026"). Use obr_efo_vintages() to see all valid labels.

what

Which EFO table to compare. Either one of the named shortcuts "fiscal" (Table 6.5, the default), "inflation" (sheet 1.7), "labour" (sheet 1.6), "output_gap" (sheet 1.14), or any table id from obr_efo_catalogue() (e.g. "6.13", "1.19"), so all detailed-forecast tables can be diffed across vintages.

refresh

Logical. If TRUE, re-download even if cached files exist. Defaults to FALSE.

Value

An obr_tbl with the standard v0.4.0 schema columns (period, period_type, series, metric_type, unit) plus value_a, value_b, and revision (value_b - value_a). Provenance points at the second vintage; the first vintage URL is recorded in the notes field.

Details

Rows are the inner join of the two vintages on the schema keys (period, period_type, series, metric_type, unit). Periods or series that are present in only one vintage are silently dropped. If you need to see what was added or removed between vintages, compare obr_efo_vintages() row counts or call the underlying functions directly with each vintage and setdiff() on the keys.

Calling the function with vintage_a == vintage_b is allowed and returns an all-zero revision column. There is no special handling beyond that.

Examples

# \donttest{
op <- options(obr.cache_dir = tempdir())
try({
  diff <- obr_compare_vintages("October 2024", "March 2026")
  diff[diff$series == "Net borrowing", ]

  # Compare the inflation forecast across two vintages
  inf_diff <- obr_compare_vintages("October 2024", "March 2026",
  what = "inflation")

  # Any catalogue table works too, e.g. debt interest (Table 6.16)
  di_diff <- obr_compare_vintages("November 2025", "March 2026",
  what = "6.16")
})
#>  Loading from cache. Use `refresh = TRUE` to re-download.
#>  Downloading efo_aggregates_march_2026.xlsx from OBR...
#>  Saved to cache.
#>  Loading from cache. Use `refresh = TRUE` to re-download.
#>  Loading from cache. Use `refresh = TRUE` to re-download.
#>  Downloading efo_aggregates_november_2025.xlsx from OBR...
#> Waiting 2s for throttling delay ■■■■■■■■■■■■■■■                 
#> Waiting 2s for throttling delay ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  
#>  Saved to cache.
#>  Loading from cache. Use `refresh = TRUE` to re-download.
options(op)
# }