missing_to_cat: Convert missing values to categorical variables

View source: R/mutate.R

missing_to_catR 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 data for conversion of missing values

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

code

Examples

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


iNZightTools documentation built on Oct. 12, 2023, 5:06 p.m.