Displaying 1 result from an estimated 1 matches for "na_factor_level".
2012 Aug 22
1
Reshaping dataframes
...bind.fill from the reshape package on two data frames I would get a data
frame like
trg_type child_type_1
1 Scientists NA
2 of used
Now to get rid of NA values I use the following function, which works for
data frames with only factor values:
substitute_na <- function(tok, na_factor_level = "NOT_REALIZED") {
for (i in 1:length(tok)) {levels(tok[,i]) <- c(levels(tok[,i]),
na_factor_level)}
tok[is.na(tok)] <- as.factor(na_factor_level)
return(tok)
}
Is there a better/faster way to do it? It would also be great to be able to
distinguish factor columns fro...