title: One of the factor's levels is an empty string; how to replace it with non-missing value?
body: <p>Data frame AEbySOC contains two columns - factor SOC with character levels and integer count Count:</p>
  
  <pre><code>&gt; str(AEbySOC)
  'data.frame':   19 obs. of  2 variables:
   $ SOC  : Factor w/ 19 levels "","Blood and lymphatic system disorders",..: 1 2 3 4 5 6 7 8 9 10 ...
   $ Count: int  25 50 7 3 1 49 49 2 1 9 ...
  </code></pre>
  
  <p>One of the levels of SOC is an empty character string:</p>
  
  <pre><code>&gt; l = levels(AEbySOC$SOC)
  &gt; l[1]
  [1] ""
  </code></pre>
  
  <p>I want to replace the value of this level by a non-empty string, say, "Not specified". This does not work:</p>
  
  <pre><code>&gt; library(plyr)
  &gt; revalue(AEbySOC$SOC, c(""="Not specified"))
  Error: attempt to use zero-length variable name
  </code></pre>
  
  <p>Neither does this:</p>
  
  <pre><code>&gt; AEbySOC$SOC[AEbySOC$SOC==""] = "Not specified"
  Warning message:
  In `[&lt;-.factor`(`*tmp*`, AEbySOC$SOC == "", value = c(NA, 2L, 3L,  :
    invalid factor level, NA generated
  </code></pre>
  
  <p>What's the right way to implement this? I appreciate any input/comment.</p>