README.md

toolR

Travis build
status AppVeyor build
status

ToolR provides basic functionality for economists. Package currently only allows CPI price conversions.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("bdempe18/toolR")

Rebase

Rebase convert prices listed in a base year’s USD to its equivalent value in a desired year.

library(toolR)

prices_2000 <- c(100,200,300)
prices_2010 <- toolR::rebase(prices_2000, in_yr = 2000, to_yr = 2010)
prices_2010
#> [1] 126.6473 253.2947 379.9420

Rebase supports vectorized operations. A sequence of prices and base years can be converted to a common year.

prices <- runif(10, 50, 100)
yrs <- 2000:2009
rebase(price=prices, in_yr = yrs, to_yr = 2012)
#>  [1] 128.44311 118.39742 105.61269 122.40534  85.92296  90.75703 107.95819
#>  [8]  55.60872  89.48802  90.09398

Rebase can be used in conjunction with dplyr to convert a data frame column to a common year.

suppressPackageStartupMessages(library(dplyr))

df <- data.frame(yr = 2000:2009, prices = runif(10, 50, 100))
df %>% mutate(prices15 = rebase(price = prices, in_yr = yr, to_yr = 2015))
#>      yr   prices  prices15
#> 1  2000 75.16783 103.45804
#> 2  2001 94.44039 126.42317
#> 3  2002 88.76840 116.96397
#> 4  2003 69.20121  89.13335
#> 5  2004 98.06781 123.03246
#> 6  2005 77.44576  93.99699
#> 7  2006 75.02880  88.22093
#> 8  2007 64.81711  74.08703
#> 9  2008 59.35769  65.35361
#> 10 2009 87.46620  96.61097


bdempe18/toolR documentation built on June 14, 2019, 12:03 a.m.