missingToCat {iNZightTools}R Documentation

Convert missing values to categorical variables

Description

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.

Usage

missingToCat(.data, vars, names = paste0(vars, "_miss"))

Arguments

.data

a dataframe with the columns to convert its missing values into categorical

vars

a character vector of the variables in .data for conversion of missing values to categorical

names

a 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)

Owen Jin

See Also

code

Examples

Run examples

missing <- missingToCat(iris, vars = c("Species", "Sepal.Length"))
cat(code(missing))
head(missing)


[Package iNZightTools version 1.12.2 Index]