| Title: | Access 'Office for Budget Responsibility' Data |
|---|---|
| Description: | Provides clean, tidy access to data published by the 'Office for Budget Responsibility' ('OBR'), the UK's independent fiscal watchdog. Covers the Public Finances Databank (outturn for PSNB, PSND, receipts, and expenditure since 1946), the Historical Official Forecasts Database (every 'OBR' forecast since 2010), the Economic and Fiscal Outlook detailed forecast tables (five-year projections from the latest Budget), the Welfare Trends Report (incapacity benefit spending and caseloads), and the Fiscal Risks and Sustainability Report (50-year state pension projections). All returned objects carry provenance metadata recording the source URL, publication vintage, retrieval time, and file fingerprint, so analyses can be audited and reproduced. Data is downloaded from the 'OBR' on first use and cached locally for subsequent calls. Data is sourced from the 'OBR' website <https://obr.uk>. |
| Authors: | Charles Coverdale [aut, cre] |
| Maintainer: | Charles Coverdale <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.0 |
| Built: | 2026-05-12 09:51:07 UTC |
| Source: | https://github.com/charlescoverdale/obr |
Standard data.frame subsetting drops the obr_tbl class. This method
preserves it (and the provenance attributes) when the result is still a
data.frame.
## S3 method for class 'obr_tbl' x[...]## S3 method for class 'obr_tbl' x[...]
x |
An |
... |
Subsetting arguments passed to [ |
An obr_tbl if the subset is two-dimensional, otherwise the
underlying vector.
Strips the provenance attributes and the obr_tbl class so the result
interacts smoothly with packages that dispatch on data.frame directly.
## S3 method for class 'obr_tbl' as.data.frame(x, ...)## S3 method for class 'obr_tbl' as.data.frame(x, ...)
x |
An |
... |
Unused. |
A plain data.frame with no provenance.
Deletes all files downloaded and cached by the obr package. The next function call will re-download fresh data from the OBR website.
clear_cache()clear_cache()
Invisibly returns NULL.
op <- options(obr.cache_dir = tempdir()) clear_cache() options(op)op <- options(obr.cache_dir = tempdir()) clear_cache() options(op)
Downloads (and caches) the OBR Economic and Fiscal Outlook Detailed Forecast Tables - Economy file and returns quarterly economic projections for a chosen measure in tidy long format.
get_efo_economy( measure = c("inflation", "labour", "output_gap"), refresh = FALSE, vintage = NULL )get_efo_economy( measure = c("inflation", "labour", "output_gap"), refresh = FALSE, vintage = NULL )
measure |
Character. Which economy table to return. One of
|
refresh |
Logical. If |
vintage |
Optional EFO vintage label such as |
Data run from 2008 Q1 through the current forecast horizon. Use
list_efo_economy_measures() to see all available measures.
An obr_tbl with the standard v0.4.0 schema (columns:
period, period_type, series, metric_type, value, unit):
Calendar quarter, e.g. "2025Q1" (character)
Always "quarter" for this function (character)
Variable name, e.g. "CPI" (character)
One of "index", "yoy_pct", "pct", "level",
classified from the series name. This is the v0.4.0 fix for the v0.3.x
issue where, e.g., CPI Index values and CPI YoY values shared a single
value column with no machine-readable distinction.
Numeric value in units described by unit
One of "index", "pct", etc., paired with metric_type
Other EFO:
get_efo_fiscal(),
get_efo_table(),
list_efo_economy_measures(),
obr_efo_catalogue()
op <- options(obr.cache_dir = tempdir()) inf <- get_efo_economy("inflation") inf[inf$series == "CPI", ] lab <- get_efo_economy("labour") # Compare CPI projections from two different EFOs inf_oct24 <- get_efo_economy("inflation", vintage = "October 2024") inf_mar26 <- get_efo_economy("inflation", vintage = "March 2026") options(op)op <- options(obr.cache_dir = tempdir()) inf <- get_efo_economy("inflation") inf[inf$series == "CPI", ] lab <- get_efo_economy("labour") # Compare CPI projections from two different EFOs inf_oct24 <- get_efo_economy("inflation", vintage = "October 2024") inf_mar26 <- get_efo_economy("inflation", vintage = "March 2026") options(op)
Downloads (and caches) the OBR Economic and Fiscal Outlook Detailed Forecast Tables - Aggregates file and returns the components of net borrowing (Table 6.5) in tidy long format.
get_efo_fiscal(refresh = FALSE, vintage = NULL)get_efo_fiscal(refresh = FALSE, vintage = NULL)
refresh |
Logical. If |
vintage |
Optional EFO vintage label such as |
Covers the five-year forecast horizon published at the most recent fiscal event. Key series include current receipts, current expenditure, depreciation, net investment, and net borrowing (PSNB). The exact vintage is recorded in the returned object's provenance attribute and visible in the printed header.
An obr_tbl with the standard v0.4.0 schema (columns:
period, period_type, series, metric_type, value, unit):
Fiscal year being forecast, e.g. "2025-26" (character)
Always "fiscal_year" for this function (character)
Component name, e.g. "Net borrowing" (character)
Always "level" for this function (character)
Projected value (numeric)
Always "gbp_bn" for this function (character)
Other EFO:
get_efo_economy(),
get_efo_table(),
list_efo_economy_measures(),
obr_efo_catalogue()
op <- options(obr.cache_dir = tempdir()) efo <- get_efo_fiscal() efo[efo$series == "Net borrowing", ] obr_provenance(efo)$vintage # Pin to a specific EFO for reproducibility october_2024 <- get_efo_fiscal(vintage = "October 2024") options(op)op <- options(obr.cache_dir = tempdir()) efo <- get_efo_fiscal() efo[efo$series == "Net borrowing", ] obr_provenance(efo)$vintage # Pin to a specific EFO for reproducibility october_2024 <- get_efo_fiscal(vintage = "October 2024") options(op)
Generic fetcher that takes an EFO table identifier (e.g. "6.5",
"1.7", "4.1") and returns the parsed contents in the standard
v0.4.0 schema. Use obr_efo_catalogue() to discover which tables
are available.
get_efo_table(table_id, vintage = NULL, refresh = FALSE)get_efo_table(table_id, vintage = NULL, refresh = FALSE)
table_id |
Character. The EFO table identifier, e.g. |
vintage |
Optional EFO vintage label (e.g. |
refresh |
Logical. If |
Internally, this function looks up table_id in the catalogue, fetches
the right workbook (Aggregates or Economy), dispatches to a layout-
specific parser, and tags every row with metric_type and unit
according to the catalogue's defaults plus per-row classification.
Coverage today: 17 fiscal Aggregates tables + 22 macro Economy tables.
One sheet (6.11 PSND year-on-year changes) is a cross-reference to a
previous EFO and returns NULL with a warning rather than data; OBR
itself directs users to the previous EFO for that table.
Headline functions get_efo_fiscal() and get_efo_economy() are kept
as thin wrappers over this dispatcher.
An obr_tbl with the standard v0.4.0 schema columns
(period, period_type, series, metric_type, value, unit).
Returns NULL (with a warning) for cross-reference sheets.
Other EFO:
get_efo_economy(),
get_efo_fiscal(),
list_efo_economy_measures(),
obr_efo_catalogue()
op <- options(obr.cache_dir = tempdir()) # Net borrowing components (same data as get_efo_fiscal()) get_efo_table("6.5") # CPI category inflation by year get_efo_table("1.19") # Composition of public sector net debt get_efo_table("6.13") # Pin to a specific vintage get_efo_table("6.5", vintage = "October 2024") options(op)op <- options(obr.cache_dir = tempdir()) # Net borrowing components (same data as get_efo_fiscal()) get_efo_table("6.5") # CPI category inflation by year get_efo_table("1.19") # Composition of public sector net debt get_efo_table("6.13") # Pin to a specific vintage get_efo_table("6.5", vintage = "October 2024") options(op)
Downloads (and caches) the OBR Public Finances Databank and returns annual Total Managed Expenditure (TME) in £ billion. TME is the broadest measure of UK government spending.
get_expenditure(refresh = FALSE)get_expenditure(refresh = FALSE)
refresh |
Logical. If |
An obr_tbl with the standard v0.4.0 schema. series is
"TME", metric_type is "level", unit is "gbp_bn". See
get_public_finances() for column definitions.
Other public finances:
get_psnb(),
get_psnd(),
get_public_finances(),
get_receipts()
op <- options(obr.cache_dir = tempdir()) tme <- get_expenditure() tail(tme) options(op)op <- options(obr.cache_dir = tempdir()) tme <- get_expenditure() tail(tme) options(op)
Downloads (and caches) the OBR Forecast Revisions Database, which decomposes each EFO-to-EFO revision in the headline Public Sector Net Borrowing forecast into three top-level components - policy, classifications and one-offs, and underlying (economic determinants) - with sub-components for each.
get_forecast_revisions(unit = c("gbp_bn", "pct_gdp"), refresh = FALSE)get_forecast_revisions(unit = c("gbp_bn", "pct_gdp"), refresh = FALSE)
unit |
Character. Either |
refresh |
Logical. If |
This is the dataset behind the "what changed?" attribution charts in OBR fiscal commentary and IFS Green Budget chapters.
An obr_tbl with columns:
Forecast vintage, e.g. "November 2024" (character).
Revision component. Top-level rows are "Total",
"Policy", "Classifications and one-offs", and "Underlying".
Sub-components carry the OBR's "of which: ..." labels (character).
Fiscal year being revised, e.g. "2024-25" (character).
Revision value, in GBP billion or per cent of GDP per
unit (numeric). A positive value indicates an upward revision to
PSNB.
Other forecasts:
get_forecasts(),
list_forecast_series(),
obr_actual_vs_forecast(),
obr_compare_vintages(),
obr_forecast_panel()
op <- options(obr.cache_dir = tempdir()) rev <- get_forecast_revisions() # Top-level revisions only rev[rev$component %in% c("Total", "Policy", "Classifications and one-offs", "Underlying"), ] options(op)op <- options(obr.cache_dir = tempdir()) rev <- get_forecast_revisions() # Top-level revisions only rev[rev$component %in% c("Total", "Policy", "Classifications and one-offs", "Underlying"), ] options(op)
Downloads (and caches) the OBR Historical Official Forecasts Database and returns a tidy long-format data frame showing every forecast the OBR has ever published for a given series. Each row is one forecast for one fiscal year, made at one fiscal event.
get_forecasts(series = "PSNB", refresh = FALSE)get_forecasts(series = "PSNB", refresh = FALSE)
series |
Character. The series to return. Use
|
refresh |
Logical. If |
This is useful for visualising how OBR forecasts have evolved over time, and for comparing forecasts against outturns. The vintage of the underlying database is recorded in the returned object's provenance.
An obr_tbl with the standard v0.4.0 schema plus a
forecast_date column (so each row identifies one fiscal-year value at
one fiscal event):
When the forecast was published, e.g. "March 2024"
Fiscal year being forecast, e.g. "2024-25"
Always "fiscal_year"
Series name as supplied (character)
One of "level", "pct", "yoy_pct", set per
series. CPI / GDP / real_GDP are "yoy_pct" (rates of change);
PSNB / receipts / expenditure are "level"; the _pct variants and
PSND are "pct" (% of GDP).
Numeric forecast value in the unit described by unit
"gbp_bn" for level series, "pct" for percentage series
Other forecasts:
get_forecast_revisions(),
list_forecast_series(),
obr_actual_vs_forecast(),
obr_compare_vintages(),
obr_forecast_panel()
op <- options(obr.cache_dir = tempdir()) get_forecasts("PSNB") psnb <- get_forecasts("PSNB") psnb[psnb$period == "2024-25", ] options(op)op <- options(obr.cache_dir = tempdir()) get_forecasts("PSNB") psnb <- get_forecasts("PSNB") psnb[psnb$period == "2024-25", ] options(op)
Downloads (and caches) the OBR Welfare Trends Report charts and tables workbook and returns the combined incapacity benefit caseload since 2008-09, in both absolute terms (thousands of claimants) and as a share of the working-age population.
get_incapacity_caseloads(refresh = FALSE)get_incapacity_caseloads(refresh = FALSE)
refresh |
Logical. If |
An obr_tbl with the standard v0.4.0 schema. The two series
("Claimants" and "Share of working age population") carry different
units: claimants are in thousands and the share is a percentage. After
calling, the caller may want to overwrite unit to "count_k" for the
claimants series, since the heuristic classifier cannot infer the
"thousands" denomination from the series name alone.
Other welfare:
get_incapacity_spending(),
get_welfare_spending()
op <- options(obr.cache_dir = tempdir()) cases <- get_incapacity_caseloads() cases[cases$series == "Claimants", ] options(op)op <- options(obr.cache_dir = tempdir()) cases <- get_incapacity_caseloads() cases[cases$series == "Claimants", ] options(op)
Downloads (and caches) the OBR Welfare Trends Report charts and tables workbook and returns annual spending on each incapacity benefit as a share of GDP, from 1978-79 to the current forecast horizon.
get_incapacity_spending(refresh = FALSE)get_incapacity_spending(refresh = FALSE)
refresh |
Logical. If |
Series include: Invalidity Benefit, Incapacity Benefit, Employment and Support Allowance (ESA), Sickness Benefit, and Severe Disablement Allowance.
An obr_tbl with the standard v0.4.0 schema. series is the
benefit name, values are spending as a percentage of GDP, metric_type
is "pct", unit is "pct". See get_public_finances() for full
column docs.
Other welfare:
get_incapacity_caseloads(),
get_welfare_spending()
op <- options(obr.cache_dir = tempdir()) ib <- get_incapacity_spending() unique(ib$series) options(op)op <- options(obr.cache_dir = tempdir()) ib <- get_incapacity_spending() unique(ib$series) options(op)
Downloads (and caches) the OBR Fiscal Risks and Sustainability Report executive summary charts and tables workbook and returns 50-year projections for state pension spending as a share of GDP, under alternative demographic and triple-lock uprating scenarios.
get_pension_projections(refresh = FALSE)get_pension_projections(refresh = FALSE)
refresh |
Logical. If |
This data is unique to the Fiscal Risks and Sustainability Report and is not available in any other OBR publication. It illustrates how ageing demographics and pension uprating rules interact to determine the long-run cost of the state pension. The exact vintage is recorded in the returned object's provenance.
An obr_tbl with the standard v0.4.0 schema plus a
scenario_type column to group scenarios:
Fiscal year, e.g. "2030-31" (character)
Always "fiscal_year"
Scenario name, e.g. "Central projection",
"Higher life expectancy" (character)
Always "pct"
State pension spending as a percentage of GDP (numeric)
Always "pct"
Either "Demographic scenarios" or
"Triple lock scenarios" (character)
op <- options(obr.cache_dir = tempdir()) proj <- get_pension_projections() central <- proj[proj$scenario_type == "Demographic scenarios" & proj$series == "Central projection", ] tail(central, 10) dem <- proj[proj$scenario_type == "Demographic scenarios", ] options(op)op <- options(obr.cache_dir = tempdir()) proj <- get_pension_projections() central <- proj[proj$scenario_type == "Demographic scenarios" & proj$series == "Central projection", ] tail(central, 10) dem <- proj[proj$scenario_type == "Demographic scenarios", ] options(op)
Downloads (and caches) the OBR Policy Measures Database, a single workbook that lists every tax or spending measure scored at a UK fiscal event, with the Exchequer effect in GBP million for each year of the forecast horizon. Tax measures cover 1970 to date; spending measures cover 2010 to date.
get_policy_measures( type = c("tax", "spending"), search = NULL, since = NULL, refresh = FALSE )get_policy_measures( type = c("tax", "spending"), search = NULL, since = NULL, refresh = FALSE )
type |
Character vector. Which measures to return: |
search |
Optional character. A regular expression used to filter
|
since |
Optional fiscal-year cut-off (e.g. |
refresh |
Logical. If |
This is the only programmatic access to the PMD: the OBR otherwise distributes it as a single Excel file.
An obr_tbl with columns:
Fiscal event that scored the measure, e.g. "Budget 2024" (character)
Plain-English description of the measure (character)
Tax head (for tax measures) or spending head (character)
Fiscal year being scored, e.g. "2024-25" (character)
Exchequer effect in GBP million. For tax measures, a positive value raises revenue; for spending measures, a positive value increases spending (numeric)
Other policy measures:
policy_measures_summary()
op <- options(obr.cache_dir = tempdir()) # The OBR CDN occasionally rate-limits or returns 403 to repeated # requests. tryCatch so the example degrades gracefully if that happens # during the CRAN check. oct24 <- tryCatch(get_policy_measures(), error = function(e) NULL) if (!is.null(oct24)) { head(oct24[grepl("2024", oct24$event) & oct24$fiscal_year == "2025-26", ]) # All alcohol-duty measures since 2010 tryCatch( get_policy_measures(type = "tax", search = "alcohol", since = "2010-11"), error = function(e) NULL ) } options(op)op <- options(obr.cache_dir = tempdir()) # The OBR CDN occasionally rate-limits or returns 403 to repeated # requests. tryCatch so the example degrades gracefully if that happens # during the CRAN check. oct24 <- tryCatch(get_policy_measures(), error = function(e) NULL) if (!is.null(oct24)) { head(oct24[grepl("2024", oct24$event) & oct24$fiscal_year == "2025-26", ]) # All alcohol-duty measures since 2010 tryCatch( get_policy_measures(type = "tax", search = "alcohol", since = "2010-11"), error = function(e) NULL ) } options(op)
Downloads (and caches) the OBR Public Finances Databank and returns annual Public Sector Net Borrowing in £ billion. A positive value means the government is borrowing (deficit); a negative value means a surplus.
get_psnb(refresh = FALSE)get_psnb(refresh = FALSE)
refresh |
Logical. If |
An obr_tbl with the standard v0.4.0 schema. series is
"PSNB", metric_type is "level", unit is "gbp_bn". See
get_public_finances() for column definitions.
Other public finances:
get_expenditure(),
get_psnd(),
get_public_finances(),
get_receipts()
op <- options(obr.cache_dir = tempdir()) psnb <- get_psnb() tail(psnb) options(op)op <- options(obr.cache_dir = tempdir()) psnb <- get_psnb() tail(psnb) options(op)
Downloads (and caches) the OBR Public Finances Databank and returns annual Public Sector Net Debt in £ billion.
get_psnd(refresh = FALSE)get_psnd(refresh = FALSE)
refresh |
Logical. If |
An obr_tbl with the standard v0.4.0 schema. series is
"PSND", metric_type is "level", unit is "gbp_bn". See
get_public_finances() for column definitions.
Other public finances:
get_expenditure(),
get_psnb(),
get_public_finances(),
get_receipts()
op <- options(obr.cache_dir = tempdir()) psnd <- get_psnd() tail(psnd) options(op)op <- options(obr.cache_dir = tempdir()) psnd <- get_psnd() tail(psnd) options(op)
Downloads (and caches) the OBR Public Finances Databank and returns all aggregate fiscal series in tidy long format. Covers outturn from 1946-47 and OBR projections through the current forecast horizon.
get_public_finances(refresh = FALSE)get_public_finances(refresh = FALSE)
refresh |
Logical. If |
Series include: Public sector net borrowing, Public sector net debt, Total managed expenditure, Public sector current receipts, Nominal GDP, GDP deflator, and more.
An obr_tbl (a data.frame with attached provenance) with the
standard v0.4.0 schema (columns: period, period_type, series,
metric_type, value, unit):
Fiscal year (character, e.g. "2024-25")
Always "fiscal_year" for this function
Series name (character)
Usually "level"; ratio or index series get a more
specific value derived from the series name
Numeric value in units described by unit
Usually "gbp_bn"; ratios and indices override
Use obr_provenance() to extract source URL, vintage, and retrieval time.
Other public finances:
get_expenditure(),
get_psnb(),
get_psnd(),
get_receipts()
op <- options(obr.cache_dir = tempdir()) pf <- get_public_finances() unique(pf$series) obr_provenance(pf) options(op)op <- options(obr.cache_dir = tempdir()) pf <- get_public_finances() unique(pf$series) obr_provenance(pf) options(op)
Downloads (and caches) the OBR Public Finances Databank and returns public sector current receipts broken down by individual tax type, in tidy long format. Coverage begins in 1999-00.
get_receipts(refresh = FALSE)get_receipts(refresh = FALSE)
refresh |
Logical. If |
An obr_tbl with the standard v0.4.0 schema (columns:
period, period_type, series, metric_type, value, unit).
series is the tax or receipt category, metric_type is "level",
unit is "gbp_bn". See get_public_finances() for full column docs.
Other public finances:
get_expenditure(),
get_psnb(),
get_psnd(),
get_public_finances()
op <- options(obr.cache_dir = tempdir()) receipts <- get_receipts() receipts[grepl("income tax", receipts$series, ignore.case = TRUE), ] options(op)op <- options(obr.cache_dir = tempdir()) receipts <- get_receipts() receipts[grepl("income tax", receipts$series, ignore.case = TRUE), ] options(op)
Downloads (and caches) the OBR Welfare Trends Report charts and tables workbook and returns annual working-age welfare spending as a share of GDP, split into incapacity-related and non-incapacity spending.
get_welfare_spending(refresh = FALSE)get_welfare_spending(refresh = FALSE)
refresh |
Logical. If |
Data cover fiscal years from 1978-79 through the current forecast horizon. The exact vintage is recorded in the returned object's provenance.
An obr_tbl with the standard v0.4.0 schema (columns:
period, period_type, series, metric_type, value, unit).
Values are spending as a percentage of GDP; metric_type is "pct",
unit is "pct".
Other welfare:
get_incapacity_caseloads(),
get_incapacity_spending()
op <- options(obr.cache_dir = tempdir()) welfare <- get_welfare_spending() welfare[welfare$series == "Working-age incapacity benefits spending" & welfare$period >= "2000-01", ] options(op)op <- options(obr.cache_dir = tempdir()) welfare <- get_welfare_spending() welfare[welfare$series == "Working-age incapacity benefits spending" & welfare$period >= "2000-01", ] options(op)
Returns a data frame of the economy measures available via
get_efo_economy(), showing the measure name to pass and a
short description of what each covers.
list_efo_economy_measures()list_efo_economy_measures()
A data frame with columns measure, sheet, and description.
Other EFO:
get_efo_economy(),
get_efo_fiscal(),
get_efo_table(),
obr_efo_catalogue()
list_efo_economy_measures()list_efo_economy_measures()
Returns a data frame showing the series names accepted by
get_forecasts(), the corresponding Excel sheet in the OBR
Historical Official Forecasts Database, and a plain-English description.
list_forecast_series()list_forecast_series()
A data frame with columns series, sheet, and description.
Other forecasts:
get_forecast_revisions(),
get_forecasts(),
obr_actual_vs_forecast(),
obr_compare_vintages(),
obr_forecast_panel()
list_forecast_series()list_forecast_series()
Joins the long-format Historical Forecasts Database for a given series
against the Public Finances Databank outturn for the same series.
Returns one row per (forecast vintage, fiscal year) where both an OBR
forecast value and an ONS outturn value exist, with the forecast error
(value_forecast - value_actual) computed.
obr_actual_vs_forecast( series = c("PSNB", "PSND", "expenditure"), refresh = FALSE )obr_actual_vs_forecast( series = c("PSNB", "PSND", "expenditure"), refresh = FALSE )
series |
Forecast series. One of |
refresh |
Logical. If |
Useful for forecast-evaluation studies, similar in shape to the OBR's own Forecast Evaluation Report decomposition.
Currently supports series for which a clean gbp_bn outturn function
exists in this package: "PSNB", "PSND", "expenditure". Other
series (CPI, GDP, percentages of GDP) need outturn from external
packages and will error.
An obr_tbl with columns forecast_date, period (fiscal year
being forecast), period_type, series, unit, value_forecast
(from HFD), value_actual (from PFD outturn), and error
(value_forecast - value_actual). Provenance points at the HFD;
the PFD source URL is recorded in notes.
Other forecasts:
get_forecast_revisions(),
get_forecasts(),
list_forecast_series(),
obr_compare_vintages(),
obr_forecast_panel()
op <- options(obr.cache_dir = tempdir()) eval <- obr_actual_vs_forecast("PSNB") # 1-year-ahead forecast errors only: # take the forecast vintage closest to the start of each fiscal year eval2425 <- eval[eval$period == "2024-25", ] eval2425[order(eval2425$forecast_date), ] options(op)op <- options(obr.cache_dir = tempdir()) eval <- obr_actual_vs_forecast("PSNB") # 1-year-ahead forecast errors only: # take the forecast vintage closest to the start of each fiscal year eval2425 <- eval[eval$period == "2024-25", ] eval2425[order(eval2425$forecast_date), ] options(op)
Returns the most recent EFO that had been published on or before date.
Useful for reproducing analyses as they would have looked at a given point
in time, before subsequent forecast revisions.
obr_as_of(date, publication = "EFO")obr_as_of(date, publication = "EFO")
date |
A Date, or anything coercible to one (e.g. |
publication |
Currently only |
A length-one character vector containing the vintage label,
e.g. "October 2024".
Other vintage:
obr_efo_vintages(),
obr_pin(),
obr_pinned(),
obr_unpin()
obr_as_of("2024-11-15") obr_as_of(Sys.Date())obr_as_of("2024-11-15") obr_as_of(Sys.Date())
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.
obr_compare_vintages( vintage_a, vintage_b, what = c("fiscal", "inflation", "labour", "output_gap"), refresh = FALSE )obr_compare_vintages( vintage_a, vintage_b, what = c("fiscal", "inflation", "labour", "output_gap"), refresh = FALSE )
vintage_a, vintage_b
|
EFO vintage labels (e.g. |
what |
Which EFO table to compare. One of |
refresh |
Logical. If |
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.
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.
Other forecasts:
get_forecast_revisions(),
get_forecasts(),
list_forecast_series(),
obr_actual_vs_forecast(),
obr_forecast_panel()
op <- options(obr.cache_dir = tempdir()) 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") options(op)op <- options(obr.cache_dir = tempdir()) 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") options(op)
Returns a data frame describing every Detailed Forecast Table in the OBR
Economic and Fiscal Outlook (Aggregates and Economy workbooks) that
get_efo_table() knows how to parse.
obr_efo_catalogue()obr_efo_catalogue()
Use this catalogue to discover which tables are available, what each
contains, and the default metric_type / unit get_efo_table() will
attach. Pass any table_id to get_efo_table().
Coverage: 17 fiscal aggregates tables (Section 6) plus 22 macro economy
tables (Section 1). One sheet (6.11) is currently a cross-reference to
a previous EFO and returns NULL with a warning rather than data.
A data frame with columns:
The EFO table identifier (e.g. "6.5", "1.7").
Which EFO workbook the table sits in: "aggregates" or
"economy".
Theme tag (e.g. "GDP", "Labour", "Debt").
Human-readable title taken from the OBR contents page.
Layout family the parser uses: "quarterly_wide",
"quarterly_single", "annual_year_wide", "fiscal_year_wide",
or "cross_reference".
Default metric_type applied to series
whose name does not signal otherwise. NA lets the heuristic decide
per row.
Default unit for the same.
Other EFO:
get_efo_economy(),
get_efo_fiscal(),
get_efo_table(),
list_efo_economy_measures()
head(obr_efo_catalogue()) # All tables in the Debt section cat <- obr_efo_catalogue() cat[cat$section == "Debt", c("table_id", "title")]head(obr_efo_catalogue()) # All tables in the Debt section cat <- obr_efo_catalogue() cat[cat$section == "Debt", c("table_id", "title")]
Returns a data frame of every EFO published since the OBR was created in
June 2010, with publication dates and the URL slug used in the OBR's
download links. Use this to look up which vintages can be pinned via
obr_pin() or passed to vintage = arguments on get_efo_fiscal() and
get_efo_economy().
obr_efo_vintages()obr_efo_vintages()
A data frame with columns:
Always "EFO".
Vintage label, e.g. "March 2026".
Publication date of the EFO (Date).
URL slug used by the OBR for that vintage's download pages.
Other vintage:
obr_as_of(),
obr_pin(),
obr_pinned(),
obr_unpin()
head(obr_efo_vintages()) tail(obr_efo_vintages(), 5)head(obr_efo_vintages()) tail(obr_efo_vintages(), 5)
Returns a data frame describing the Charter for Budget Responsibility
fiscal rules currently in force, as encoded in the package at the time
of release. Numerical headroom against each rule is not shipped as a
constant because it is updated at every fiscal event and would go stale
within months; users should derive headroom from the current EFO output
of get_efo_fiscal(), or consult the OBR's EFO press release for the
relevant vintage.
obr_fiscal_rules()obr_fiscal_rules()
The current Charter (Autumn 2024, with an Autumn 2025 update) sets three numerical rules:
Stability rule: current budget in balance or surplus by the target year. The target year is the 5th forecast year and rolls to the 3rd forecast year from 2026-27 onwards.
Investment rule: Public Sector Net Financial Liabilities (PSNFL) as a share of GDP falling year-on-year by the target year.
Welfare cap: AME-capped welfare spending below the statutory cap level by the target year.
The Budget Responsibility Act 2024 also adds a non-numerical fiscal lock requiring an OBR forecast for any fiscally significant measure.
A data frame with columns:
Short rule code: "stability", "investment", "welfare_cap".
The metric the rule binds on.
Plain-English target.
How the target year is set under the Charter.
Sign convention for headroom.
Charter version that defines the rule.
Act of Parliament backing the rule.
obr_fiscal_rules()obr_fiscal_rules()
Takes the long-format Historical Forecasts Database output of
get_forecasts() and pivots it to a wide panel with one row per
forecast vintage (e.g. "March 2024") and one column per fiscal year
being forecast (e.g. "2024-25"). The first column is the forecast
vintage; remaining columns are numeric forecast values.
obr_forecast_panel( series = "PSNB", refresh = FALSE, order_chronologically = TRUE )obr_forecast_panel( series = "PSNB", refresh = FALSE, order_chronologically = TRUE )
series |
Character. Series to return; see |
refresh |
Logical. If |
order_chronologically |
Logical. If |
This format mirrors how the OBR's own Historical Forecasts Database is laid out and how forecast-error studies (e.g. the OBR's own Forecast Evaluation Report) decompose performance: each row is one forecast published at a fiscal event, each column is the target year being forecast, and the diagonal-like structure lets you read the h-step ahead forecast for any vintage.
An obr_tbl whose first column (forecast_date) is character
and whose remaining columns are numeric forecast values, one per
fiscal year. Provenance is inherited from the underlying call to
get_forecasts() and a notes field describes the panel.
Other forecasts:
get_forecast_revisions(),
get_forecasts(),
list_forecast_series(),
obr_actual_vs_forecast(),
obr_compare_vintages()
op <- options(obr.cache_dir = tempdir()) panel <- obr_forecast_panel("PSNB") # PSNB forecast for 2024-25 across every vintage panel[, c("forecast_date", "2024-25")] options(op)op <- options(obr.cache_dir = tempdir()) panel <- obr_forecast_panel("PSNB") # PSNB forecast for 2024-25 across every vintage panel[, c("forecast_date", "2024-25")] options(op)
Sets the EFO vintage that get_efo_fiscal() and get_efo_economy() will
use when called without an explicit vintage = argument. The pin is stored
as the option obr.efo_vintage and lasts for the R session unless
overwritten or removed via obr_unpin().
obr_pin(vintage = NULL)obr_pin(vintage = NULL)
vintage |
Vintage label such as |
Invisibly returns the pinned vintage string, or NULL after
clearing.
Other vintage:
obr_as_of(),
obr_efo_vintages(),
obr_pinned(),
obr_unpin()
op <- options(obr.cache_dir = tempdir()) obr_pin("October 2024") obr_pinned() obr_unpin() options(op)op <- options(obr.cache_dir = tempdir()) obr_pin("October 2024") obr_pinned() obr_unpin() options(op)
Returns the vintage string currently active via obr_pin(), or NULL
if no pin is set.
obr_pinned()obr_pinned()
Either a length-one character vector or NULL.
Other vintage:
obr_as_of(),
obr_efo_vintages(),
obr_pin(),
obr_unpin()
obr_pinned()obr_pinned()
Returns the provenance list attached to an obr_tbl: the OBR publication
it came from, the publication vintage, the source URL, retrieval time,
file fingerprint, and package version.
obr_provenance(x)obr_provenance(x)
x |
An |
A named list of provenance fields, or NULL if no provenance is
attached. Fields:
Short code: "PFD", "HFD", "EFO", "WTR", "FSR", "PMD".
Publication vintage label, e.g. "March 2026".
Canonical OBR download URL the data came from.
POSIXct timestamp of when the file was downloaded or
last validated in the cache.
MD5 fingerprint of the underlying spreadsheet.
obr package version that produced the object.
Optional free-text notes, or NULL.
op <- options(obr.cache_dir = tempdir()) psnb <- get_psnb() obr_provenance(psnb) options(op)op <- options(obr.cache_dir = tempdir()) psnb <- get_psnb() obr_provenance(psnb) options(op)
Removes any pin set by obr_pin(). After unpinning, get_efo_fiscal()
and get_efo_economy() revert to resolving the most recent live EFO via
the dynamic URL resolver.
obr_unpin()obr_unpin()
Invisibly returns the previously pinned vintage (or NULL if no
pin was set).
Other vintage:
obr_as_of(),
obr_efo_vintages(),
obr_pin(),
obr_pinned()
op <- options(obr.cache_dir = tempdir()) obr_pin("March 2025") obr_unpin() options(op)op <- options(obr.cache_dir = tempdir()) obr_pin("March 2025") obr_unpin() options(op)
Aggregates the measures returned by get_policy_measures() to give the
net Exchequer effect (positive = revenue-raising / spending-reducing for
tax, spending-increasing for spending) by fiscal event and fiscal year.
policy_measures_summary(x)policy_measures_summary(x)
x |
An |
An obr_tbl with columns:
"tax" or "spending"
Fiscal event
Fiscal year
Sum of the Exchequer effect across all measures scored at that event, in GBP million
Provenance is preserved.
Other policy measures:
get_policy_measures()
op <- options(obr.cache_dir = tempdir()) pm <- get_policy_measures(type = "tax", since = "2024-25") policy_measures_summary(pm) options(op)op <- options(obr.cache_dir = tempdir()) pm <- get_policy_measures(type = "tax", since = "2024-25") policy_measures_summary(pm) options(op)
Prints the data with a provenance header that names the OBR publication, vintage, source URL, retrieval time, and underlying file fingerprint.
## S3 method for class 'obr_tbl' print(x, n = 10L, ...)## S3 method for class 'obr_tbl' print(x, n = 10L, ...)
x |
An |
n |
Number of rows to display (default 10). |
... |
Further arguments passed to |
The input, returned invisibly.
Returns the full provenance card and a structural summary of the data.
## S3 method for class 'obr_tbl' summary(object, ...)## S3 method for class 'obr_tbl' summary(object, ...)
object |
An |
... |
Unused. |
Invisibly returns the provenance list.