I would not use gsub here - semantically, I think of gsub as replacing parts within a string. To replace an entire string, I would just use a subset. And since you're looking for a fixed string ( '' ), it doesn't even need regular expressions:
x[x == ''] = 'taco'
(Of course, this reassigns the original vector x , while gsub just returns the modified result.)
source share