make.dumNA {quest} | R Documentation |
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")
Arguments
data |
data.frame of data. |
vrb.nm |
character vector of colnames from |
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. |
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)
.
See Also
Examples
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