One of the factor's levels is an empty string; how to replace it with non-missing value?

levels(AEbySOC$SOC)[1] <- "Not specified"

Created a toy example:

df<- data.frame(a= c("", "a", "b"))

df
#  a
#1  
#2 a
#3 b

levels(df$a)
#[1] ""  "a" "b"

levels(df$a)[1] <- "Not specified"

levels(df$a)
#[1] "Not specified" "a"             "b" 

EDIT

As per the OP's comments if we need to find it according the value then in such case, we can try

levels(AEbySOC$SOC)[levels(AEbySOC$SOC) == ""] <- "Not specified"

Something like that should work:

test <- data.frame(a=c("a", "b", "", "  "))
str(test)

which.one <- which( levels(test$a) == "" )
levels(test$a)[which.one] <- "NA"