Skip to contents

Load any auxiliary data

Usage

pip_load_aux(
  measure = NULL,
  root_dir = Sys.getenv("PIP_ROOT_DIR"),
  maindir = pip_create_globals(root_dir)$PIP_DATA_DIR,
  msrdir = fs::path(maindir, "_aux", measure),
  version = NULL,
  file_to_load = NULL,
  apply_label = TRUE,
  verbose = getOption("pipload.verbose"),
  preferred_format = NULL
)

Arguments

measure

character: Measure to be used. e.g., "cpi" or "ppp".

root_dir

character: root directory of the PIP data

maindir

character: main directory. By default it uses pip_create_globals(root_dir)$PIP_DATA_DIR

msrdir

character: measure (CPI) directory. created on pip_prices().

version

An integer or a quoted directive. "available": displays list of available versions for measure. "select"|"pick"|"choose": allows user to select the vintage of measure. if the integer is a zero or a negative number (e.g., -1), pip_load_aux will load that number of versions before the most recent version available. So, if 0, it loads the current version. If -1, it will load the version before the current, -2 loads two versions before the current one, and so on. If it is a positive number, it must be quoted (as character) and in the form "%Y%m%d%H%M%S".

file_to_load

character: file path to load. Does not work with any other argument

apply_label

logical: if TRUE, predefined labels will apply to data loaded using file_to_load argument. Default TRUE. Tip: change to FALSE if the main structure of data has changed and labels have not been updated

verbose

logical: whether to display message. Default is TRUE

preferred_format

character: preferred format. default is "fst".

Value

data.table

Examples

# Load CPI
cpi <- pip_load_aux("cpi")
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied

# load PPP
ppp <- pip_load_aux("ppp")
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied

# Load GDP
gdp <- pip_load_aux("gdp")
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied

measure <- "cpi"
av      <- pip_load_aux(measure, version = "available")
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied
head(av)
#> Error in head(av): object 'av' not found
df      <- pip_load_aux(measure, version = av[1])
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied
head(df)
#>                                               
#> 1 function (x, df1, df2, ncp, log = FALSE)    
#> 2 {                                           
#> 3     if (missing(ncp))                       
#> 4         .Call(C_df, x, df1, df2, log)       
#> 5     else .Call(C_dnf, x, df1, df2, ncp, log)
#> 6 }                                           
df      <- pip_load_aux(measure, version = -1)
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied
head(df)
#>                                               
#> 1 function (x, df1, df2, ncp, log = FALSE)    
#> 2 {                                           
#> 3     if (missing(ncp))                       
#> 4         .Call(C_df, x, df1, df2, log)       
#> 5     else .Call(C_dnf, x, df1, df2, ncp, log)
#> 6 }                                           
if (FALSE) {
df      <- pip_load_aux(measure, version = "pick")
}