Learn R Programming

quest (version 0.2.0)

make.dumNA: Make Dummy Columns For Missing Data.

Description

make.dumNA makes dummy columns (i.e., dichomotous numeric vectors coded 0 and 1) for missing data. Each variable is treated in isolation.

Usage

make.dumNA(data, vrb.nm, ov = FALSE, rtn.lgl = FALSE, suffix = "_m")

Value

data.frame of numeric (logical if rtn.lgl = TRUE) columns where missing = 1 and observed = 0 (flipped if ov = TRUE) for each variable. The colnames are created by paste0(vrb.nm, suffix).

Arguments

data

data.frame of data.

vrb.nm

character vector of colnames from data specifying the variables.

ov

logical vector of length 1 specifying whether the dummy columns should be reverse coded such that missing values = 0/FALSE and observed values = 1/TRUE.

rtn.lgl

logical vector of length 1 specifying whether the dummy columns should be logical vectors (TRUE) rather than numeric vectors (FALSE).

suffix

character vector of length 1 specifying the string that should be appended to the end of the colnames in the return object.

See Also

make.dummy

Examples

Run this code
make.dumNA(data = airquality, vrb.nm = c("Ozone","Solar.R"))
make.dumNA(data = airquality, vrb.nm = c("Ozone","Solar.R"),
   rtn.lgl = TRUE) # logical vectors returned
make.dumNA(data = airquality, vrb.nm = c("Ozone","Solar.R"),
   ov = TRUE, suffix = "_o") # 1 = observed value

Run the code above in your browser using DataLab