Skip to contents

Loads datalibweb data

Usage

pip_load_dlw(
  country = NULL,
  year = NULL,
  survey_acronym = NULL,
  vermast = NULL,
  veralt = NULL,
  module = NULL,
  tool = c("PC", "TB"),
  survey_id = NULL,
  condition = NULL,
  type = c("dataframe", "list"),
  root_dir = Sys.getenv("PIP_ROOT_DIR"),
  dlw_dir = pip_create_globals(root_dir)$DLW_RAW_DIR,
  filter_to_pc = TRUE,
  filter_to_tb = FALSE,
  verbose = getOption("pipload.verbose")
)

Arguments

country

character: vector of ISO3 country codes.

year

numeric: survey year

survey_acronym

character: Survey acronym

vermast

character: Master version in the form v## or ##

veralt

character: Alternative version in the form v## or ##

module

character: combination of tool and source separated by a hyphen (e.g., PC-GPWG)

tool

character: PIP tool in which data will be used. It could be PC for Poverty Calculator or TB for Table Maker. Others will be added

survey_id

character: Vector with survey IDs like 'HND_2017_EPHPM_V01_M_V01_A_PIP_PC-GPWG'

condition

character: logical condition that applies to all surveys. For example, "year > 2012". Make sure the condition uses the names of the variables in pip_load_inventory(): orig, filename, country_code, year, survey_acronym, vermast, veralt, collection, module, tool, and source. Can't be used with arguments country, year, survey_acronym , vermast, veralt, module or tool.

type

character: Either dataframe or list. Defaults is dataframe.

root_dir

character: root directory of the PIP data

dlw_dir

character: path of datalibweb raw data

filter_to_pc

logical: If TRUE filter most recent data to be included in the Poverty Calculator. Default if FALSE

filter_to_tb

logical: If TRUE filter most recent data to be included in the Table Maker. Default if FALSE

verbose

logical: whether to display message. Default is TRUE

Value

data.table

Examples

# ONe year and one country
df <- pip_load_dlw(country = "PRY",
              year    = 2017)
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied

# specific years for one country
df <- pip_load_dlw(
            country = "PRY",
            year = c(2010, 2012)
)
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied

# country FHF does not exist so it will be part of `fail` output (No error)
df <- pip_load_dlw(
       country = c("ARG", "FHF"),
       year = 2010
)
#> ! 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 a different module (e.g., GPWG)
df <- pip_load_dlw(country = "PRY",
             year = 2010,
             module = "GPWG")
#> ! 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 using Survey ID
df <- pip_load_dlw(survey_id = c("HND_2017_EPHPM_V01_M_V02_A_GMD_GPWG",
                            "HND_2018_EPHPM_V01_M_V02_A_GMD_GPWG")
                            )
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied
# Use condition argument
df <- pip_load_dlw(condition = "country_code %chin% c('PRY', 'KGZ') &
                    (surveyid_year >= 2012 & surveyid_year < 2014)")
#> ! root_dir is not defined. Directory paths will lack network-drive root
#> directory
#> Error: [EACCES] Failed to make directory '/PIP-Data_QA': permission denied

if (FALSE) {
# more than two years for more than one country (only firt year will be used)
pip_load_dlw(
       country = c("PRY", "ARG"),
       year = c(2010, 2012)
)

# all countries and years
pip_load_dlw()
}