View source: R/Apply_Lookups.R
replace_nas_with_unlabeled | R Documentation |
Replace NAs in one variable of a data frame with a specified valued
replace_nas_with_unlabeled(data, var, replacement = "Unlabeled")
data |
A data frame |
var |
The variable to have NAs removed |
replacement |
Charater string that will replace NAs, by default "Unlabeled" |
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" )
Returns a data frame with the var values replaced with replacement, otherwise identical to the original data frame
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.