I have a factor variable in my data frame with values where in the original CSV "NA" was intended to mean simply "None", not missing data. Hence I want replace every value in the given column with "None" factor value. I tried this:
DF$col[is.na(DF$col)] <- "None"
but this throws the following error:
Warning message:
In `[<-.factor`(`*tmp*`, is.na(DF$col), value = c(NA, NA, :
invalid factor level, NA generated
I guess this is because originally there is no "None" factor level in the column, but is it the true reason? If so, how could I add a new "None" level to the factor?
(In case you would ask why didn't I convert NAs into "None" in the read.csv
phase: in other columns NA really does mean missing data).