calc.gdpdeflator <- function(deflatorfile, referenceyear)
{
gdpdef <- read.csv(deflatorfile)
gdpdef$year <- ymd(gdpdef$DATE) %>% year()
gdpdef <- gdpdef %>%
select(year, GDPDEF) %>%
group_by(year) %>%
summarise(GDPDEF = mean(GDPDEF)) %>%
data.frame()
row.names(gdpdef) <- gdpdef$year
reference_deflation <- gdpdef[referenceyear,'GDPDEF']
gdpdef <- gdpdef %>%
mutate(deflator = reference_deflation / GDPDEF) %>%
select(-GDPDEF) %>%
dplyr::rename(cost.yr = year)
gdpdef
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.