Hello. I was wondering if I could ask how to recode a factor that is either names null or empty. I have some data with 4 responses, "", "healthy", "not_healthy", and "NA". I want to recategorize "" and "NA" as "healthy". I was able to do the latter, but not the former.
> aa <- data.wide_all[1:10000, ]
> fct_count(aa$health_status, prop = TRUE)
# A tibble: 4 x 3
f n p
<fct> <int> <dbl>
1 "" 860 0.086
2 "healthy" 6393 0.639
3 "not_healthy" 2435 0.244
4 NA 312 0.0312
> aa$health_status <- fct_explicit_na(aa$health_status, na_level = "healthy")
> fct_count(aa$health_status, prop = TRUE)
# A tibble: 3 x 3
f n p
<fct> <int> <dbl>
1 "" 860 0.086
2 "healthy" 6705 0.670
3 "not_healthy" 2435 0.244
This solution did not work
aa$health_status<- factor(recode(aa$health_status, NULL = 'healthy'))
nor did calling it "", "NULL", or using a period. Any help would be appreciated!