Skip to content

Commit

Permalink
Removed PPI code into a data script to make it available to the package
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Lucey committed Nov 28, 2023
1 parent 127a074 commit 27bbbb1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
15 changes: 8 additions & 7 deletions R/adjust_inflation.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ adjust_inflation <- function(comland, refYear, refMonth){
#This isn't working right now - using downloaded file
# temp <- tempfile()
# download.file("http://download.bls.gov/pub/time.series/wp/wp.data.3.ProcessedFoods", temp)
inflate <- data.table::as.data.table(read.delim(here::here('data-raw', 'wp.data.3.ProcessedFoods')))
#inflate <- data.table::as.data.table(read.delim(comlandr::wp.data.3.ProcessedFoods))
#unlink(temp)

inflate[, series_id := gsub(" ", "", inflate[, series_id])]
deflate <- inflate[series_id == "WPU0223", ]
deflate[, MONTH := as.numeric(substr(period, 2, 3))]
data.table::setnames(deflate, c('year', 'value'), c('YEAR', 'PPI'))
deflate <- deflate[, list(YEAR, MONTH, PPI)]

# inflate[, series_id := gsub(" ", "", inflate[, series_id])]
# deflate <- inflate[series_id == "WPU0223", ]
# deflate[, MONTH := as.numeric(substr(period, 2, 3))]
# data.table::setnames(deflate, c('year', 'value'), c('YEAR', 'PPI'))
# deflate <- deflate[, list(YEAR, MONTH, PPI)]
#Set yearly deflator to 0 instead of 13 to match unknown month designation
deflate <- comlandr::deflate
deflate[MONTH == 13, MONTH := 0]
deflate.base <- deflate[YEAR == refYear & MONTH == refMonth, PPI]

Expand Down
12 changes: 12 additions & 0 deletions data-raw/create_deflate.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Area for all species
library(data.table); library(usethis); library(here)

inflate <- data.table::as.data.table(read.delim(here::here('data-raw', 'wp.data.3.ProcessedFoods')))

inflate[, series_id := gsub(" ", "", inflate[, series_id])]
deflate <- inflate[series_id == "WPU0223", ]
deflate[, MONTH := as.numeric(substr(period, 2, 3))]
data.table::setnames(deflate, c('year', 'value'), c('YEAR', 'PPI'))
deflate <- deflate[, list(YEAR, MONTH, PPI)]

usethis::use_data(deflate)
Binary file added data/deflate.rda
Binary file not shown.

0 comments on commit 27bbbb1

Please sign in to comment.