View source: R/adj_inflation.R
adj_inflation | R Documentation |
This is modeled after blscrapeR::inflation_adjust
that joins a data frame with an inflation adjustment table from the Bureau of Labor Statistics' Consumer Price Index, then calculates adjusted values. It returns the original data frame with two additional columns for adjustment factors and adjustment values.
adj_inflation(data, value, year, base_year = 2022, verbose = TRUE, key = NULL)
data |
A data frame containing monetary values by year. |
value |
Bare column name of monetary values; for safety, has no default. |
year |
Bare column name of years; for safety, has no default. |
base_year |
Year on which to base inflation amounts. Defaults to 2022, which corresponds to saying "... adjusted to 2022 dollars." |
verbose |
Logical: if |
key |
A string giving the BLS API key. If |
Note: Because adj_inflation
makes API calls, internet access is required.
According to the BLS research page, the series this uses is best suited to data going back to about 2000, when their methodology changed. For previous years, a more accurate version of the index is available on their site.
A data frame with two additional columns: adjustment factors, and adjusted values. The adjusted values column is named based on the name supplied as value
; e.g. if value = avg_wage
, the adjusted column is named adj_avg_wage
.
## Not run:
wages <- data.frame(
fiscal_year = 2010:2016,
wage = c(50000, 51000, 52000, 53000, 54000, 55000, 54000)
)
adj_inflation(wages, value = wage, year = fiscal_year, base_year = 2016)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.