I'm trying to assign my NAs to "unknown" in my dataset by doing the following code.
str(df$Var)
Factor w/ 4 levels "Current smoker",..: NA NA NA NA NA NA NA
df$Var<- ifelse(is.na(df$Var),"unknown",df$Var)
After I ran the code the string is changed
str(df$Var
chr [1:100] "unknown" "1" "1"
``
Is there way that I can assign the NAs to "unknown" without losing my variables names to "1","2","3"
I hope that my question is clear
Aucun commentaire:
Enregistrer un commentaire