This short example illustrates one of possible ways of introducing a new level into a factor:
x <- factor(c(NA, NA, "a", "b", NA, "b"))
x[is.na(x)] <- "c" # this won't work, no such level as "c" in levels(x)
## Warning message:
## In `[<-.factor`(`*tmp*`, is.na(x), value = "c") :
## invalid factor level, NA generated
levels(x) <- c(levels(x), "c") #include a new category
x[is.na(x)] <- "c"
x
## [1] c c a b c b