Skip to contents

Fetch HILDA data from the HILDA fst files created by hil_setup(). To set default variables for hil_fetch() to fetch see hil_user_default_vars().

Usage

hil_fetch(
  years = NULL,
  vars = NULL,
  new_varnames = NULL,
  add_population_weight = TRUE,
  add_basic_vars = TRUE,
  add_geography = FALSE,
  hilda_fst_dir = ifelse(!is.null(getOption("HILDA_FST")), getOption("HILDA_FST"),
    get_hilda_fst_path())
)

Arguments

years

This argument allow you to specify the years of HILDA that you like to load instead of using alphabets. The first wave of HILDA was in 2001 and known as wave 'a', and the following year was wave 'b'. To load multiple waves you can be put use a numeric vector (e.g.,2001:2009 would load all waves between 2001 and 2009).

vars

a vector containing all desired variable names to be loaded. vars can be set to "all" to fetch all columns. This may take a long time to load

new_varnames

a vector contains character names with its length equals length of vars to be replaced by vars orgininal names.

add_population_weight

take a logical value whether to add cross-sectional responding person weight column and enumerated weight column to the data

add_basic_vars

take a logical value whether to add hgage (age), hgsex (sex), mrcurr (marital status) and hhrih (relationship in household) to the data

add_geography

take a logical value whether to add hhsgcc (Greater statistical region) to the data

hilda_fst_dir

a directory where HILDA files in fst format are stored by hil_setup(). If not given the function will check uses for 'HILDA_FST' in your .Rprofile file first, then in .Renviron file.

Value

a data.table object

Examples

if (FALSE) {
summary(hil_fetch(2011))

summary(hil_fetch(2011:2012, vars = "losat"))

# Query all variables that start with 'hs' (Housing)
summary(hil_fetch(2011, vars = hil_vars("^hs")))

# Query all variables with the word 'coronavirus' in their variable description.
summary(hil_fetch(2020, vars = hil_labs("coronavirus")))
}