library(readxl)
## read in the downloaded cpi index data
data <- read_excel(path = paste0("data-raw/","CPI index 16-06-20",".xls"),
sheet = "data",
range = "B7:B198",
col_names = FALSE)
cpi_value <- as.vector(as.matrix(data))
cpi_value <- as.numeric(cpi_value)
### create a year and month indicator from Jan 2004 to December of the
### current year of APS data
year <- rep(2004:2019,each=12)
month <- rep(seq(1:12),2019-2004+1)
cpi <- matrix(c(year,month,cpi_value),
byrow=FALSE,
ncol=3, dimnames = list(NULL,
c("year","month","cpi_value")))
# rebase to the most recent month of APS data
cpi[,"cpi_value"] <- 100*(cpi[,"cpi_value"]/(cpi[length(cpi[,"cpi_value"]),"cpi_value"]))
print(paste0("Base Year = ",cpi[length(cpi[,"year"]),"year"]))
print(paste0("Base Month = ",cpi[length(cpi[,"month"]),"month"]))
aps_cpi <- cpi
usethis::use_data(aps_cpi,overwrite=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.