missing_to_cat {iNZightTools} | R Documentation |
Convert missing values to categorical variables
Description
Turn <NA>
in categorical variables into "(Missing)"
;
numeric variables will be converted to categorical variables where numeric
values as "(Observed)"
and NA
as "(Missing)"
.
Usage
missing_to_cat(data, vars, names = NULL)
Arguments
data |
a dataframe with the columns to convert its missing values into categorical |
vars |
a character vector of the variables in |
names |
a character vector of names for the new variables |
Value
original dataframe containing new columns of the converted variables for the missing values with tidyverse code attached
Author(s)
Zhaoming Su
See Also
Examples
missing <- missing_to_cat(iris, vars = c("Species", "Sepal.Length"))
cat(code(missing))
head(missing)
[Package iNZightTools version 2.0.1 Index]