% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare.R
\name{obr_compare_vintages}
\alias{obr_compare_vintages}
\title{Compare two EFO vintages}
\usage{
obr_compare_vintages(vintage_a, vintage_b, what = "fiscal", refresh = FALSE)
}
\arguments{
\item{vintage_a, vintage_b}{EFO vintage labels (e.g. \code{"October 2024"},
\code{"March 2026"}). Use \code{\link[=obr_efo_vintages]{obr_efo_vintages()}} to see all valid labels.}

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

\item{refresh}{Logical. If \code{TRUE}, re-download even if cached files
exist. Defaults to \code{FALSE}.}
}
\value{
An \code{obr_tbl} with the standard v0.4.0 schema columns
(\code{period}, \code{period_type}, \code{series}, \code{metric_type}, \code{unit}) plus
\code{value_a}, \code{value_b}, and \code{revision} (\code{value_b - value_a}).
Provenance points at the second vintage; the first vintage URL is
recorded in the \code{notes} field.
}
\description{
Pulls the same EFO table from two vintages and returns a tidy diff with
a revision column (\code{value_b - value_a}). Useful for quantifying how the
OBR's view changed between fiscal events.
}
\details{
Rows are the \strong{inner join} of the two vintages on the schema keys
(\code{period}, \code{period_type}, \code{series}, \code{metric_type}, \code{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
\code{obr_efo_vintages()} row counts or call the underlying functions
directly with each vintage and \code{setdiff()} on the keys.

Calling the function with \code{vintage_a == vintage_b} is allowed and
returns an all-zero \code{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")
})
options(op)
}

}
\seealso{
Other forecasts: 
\code{\link{get_forecast_revisions}()},
\code{\link{get_forecasts}()},
\code{\link{list_forecast_series}()},
\code{\link{obr_actual_vs_forecast}()},
\code{\link{obr_forecast_panel}()}
}
\concept{forecasts}
