I have the following data frame named as "train". columns bflag and zfactor are factor and the other 2 columns are numeric. I want to replace missing values of the factor columns with mode and the missing values of numeric variables with mean in the same data frame. How i can do this in R?
ID bflag vcount zfactor vnumber
1 0 12 1 12
2 1 NA 0 8
3 0 3 0 9
4 1 13 0 NA
5 1 2 1 2
6 NA 10 NA NA