How do I replace an empty string?
This:
x = c("","b")
gsub("","taco",x)
produces:
"taco" "tacobtaco"
instead of:
"taco" "b"
Is there any way to replace an empty string?
I would use nchar
here:
x[nchar(x)==0] <- "taco"
EDIT
If you are looking for performance so you should use nzchar:
x[!nzchar(x)] <- "taco"