| get_revisions | R Documentation |
Computes revisions in vintage data based on specified reference points: a fixed reference date, the nth release, or a specified interval. This function allows users to analyze differences between data vintages across time.
get_revisions(df, interval = NULL, nth_release = NULL, ref_date = NULL)
df |
A data frame containing vintage data. The data frame must include at least the following columns:
|
interval |
A positive integer specifying the lag (in periods) between
vintages to compute revisions.
Defaults to |
nth_release |
A positive integer or |
ref_date |
A date specifying the fixed reference publication date to compare all vintages against. |
The function supports three mutually exclusive methods for calculating revisions:
Reference date (ref_date): Computes revisions relative to a
fixed publication date.
Interval (interval): Computes revisions relative to vintages
published interval periods earlier.
Nth release (nth_release): Computes revisions relative to the
nth vintage release for each reference period.
If no method is explicitly specified, interval = 1 is used by default.
Input validation ensures that only one of ref_date, nth_release, or
interval is specified.
A data frame (tibble) of class tbl_revision, with the
following columns:
pub_date: The publication date of the vintage.
time: The reference period (e.g., quarter or month).
value: The calculated revision, i.e., the difference between the
observed value and the reference value.
Other revision utilities:
get_days_to_release(),
get_first_release(),
get_fixed_release(),
get_latest_release(),
get_nth_release(),
get_releases_by_date()
# Example data
df <- dplyr::filter(reviser::gdp, id == "US")
# Calculate revisions using an interval of 1
revisions_interval <- get_revisions(df, interval = 1)
# Calculate revisions using a fixed reference date
revisions_date <- get_revisions(df, ref_date = as.Date("2023-02-01"))
# Calculate revisions relative to the nth release (2nd release)
revisions_nth <- get_revisions(df, nth_release = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.