md_clean_data: Clean data (micro)

View source: R/md_clean_data.R

md_clean_dataR Documentation

Clean data (micro)

Description

Clean microdata to be used in PIP methods.

Usage

md_clean_data(dt, welfare, weight = NULL, quiet = FALSE)

Arguments

dt

data.frame: A table with survey data.

welfare

character: Name of welfare column.

weight

character: Name of weight column. Optional.

quiet

logical: If TRUE output messages are suppressed.

Details

md_clean_data() returns a list of elements whose main object is a data.table with the necessary transformations to be included in PIP methods. Data is available in element ⁠$data⁠. The other elements provide the number of observations that were modified depending on test performed. The name of elements are in the form p_s, where p (or prefix) refers to the test and s (the suffix) refers to the name of the variable evaluated.

Prefixes are:

  • nna: Number of NA in variable

  • nng: Number of negative values

  • ina: Index of obs with NA in variable

  • ing: Index of obs with negative values

Value

list

Examples

# Load example data
data("md_GHI_2000_income")

# Clean microdata
res <- wbpip:::md_clean_data(
  md_GHI_2000_income,
  welfare = "welfare",
  weight = "weight")
res$data


PIP-Technical-Team/wbpip documentation built on Nov. 29, 2024, 6:57 a.m.