I have a data frame of around 100 columns. I want to find a way to change empty cells to a "Missing" value in all columns that are factors. After extensive search, I managed to find a few solutions online
mutate_if(is.factor, fct_explicit_na, na_level = "Missing")
mutate_if(is.factor, ~replace_na(., "Missing"))
mutate(across(where(is.factor), ~fct_explicit_na(., na_level = "Missing"))
none of which unfortunately work.
The whole code i am using
TempData <- TempData %>% transform( A = as.factor(A) ,B = as.factor(B) ,C = as.factor(C) ,D = as.factor(D)) %>% mutate_if(is.factor, fct_explicit_na, na_level = "Missing")
In what other way can I replace empty values to "Missing" in a way that I dont have to type every single column.