replace_nas_with_unlabeled: Replace NAs in one variable of a data frame with a specified...

View source: R/Apply_Lookups.R

replace_nas_with_unlabeledR Documentation

Replace NAs in one variable of a data frame with a specified valued

Description

Replace NAs in one variable of a data frame with a specified valued

Usage

replace_nas_with_unlabeled(data, var, replacement = "Unlabeled")

Arguments

data

A data frame

var

The variable to have NAs removed

replacement

Charater string that will replace NAs, by default "Unlabeled"

Details

This function is intended for preparing columns for use. As far as the function creator understands it, NAs do not match to NAs. However, we often wish to include NAs in a graph under a proper name, such as Unlabeled and with a color of our choosing. One critical step in this process is the addition of the replacement term to the levels of the var factor. Which means we should probably add input protection when non factors are passed. I also haven't tested the handling if multiple columns are passed, I think it may not work.

VAR.long.DF<-replace_nas_with_unlabeled(data=data.DF ,var="SubCustomer") replacement = "Uncategorized" )

Value

Returns a data frame with the var values replaced with replacement, otherwise identical to the original data frame


CSISdefense/csis360 documentation built on Aug. 31, 2024, 12:35 a.m.