missingToCat {iNZightTools} | R Documentation |
Turn <NA>'s into a "missing" character; hence numeric variables will be converted to categorical variables with any numeric values will be converted to "observed", and returns the result along with tidyverse code used to generate it.
missingToCat(.data, vars, names = paste0(vars, "_miss"))
.data |
a dataframe with the columns to convert its missing values into categorical |
vars |
a character vector of the variables in |
names |
a vector of names for the new variables |
original dataframe containing new columns of the converted variables for the missing values with tidyverse code attached
Owen Jin
missing <- missingToCat(iris, vars = c("Species", "Sepal.Length"))
cat(code(missing))
head(missing)