Nothing
#
# replace NA values with "BLANK" for factor variables
#
# Author: Justin Hemann
#
# define generic function
#
CleanNaFromFactor <- function(x, ...) {
UseMethod("CleanNaFromFactor", x)
}
CleanNaFromFactor.factor = function(x, replacement="BLANK", ...) {
naCount <- sum( is.na(x) ) # count of occurences of NA
if (naCount > 0) {
# add the "BLANK" factor
x <- factor(x, levels = c(levels(x),replacement))
# replace NAs with BLANK in this variable
x[is.na(x)] <- replacement
}
# return the factor
return(x)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.