title: R: Error using recode function to replace blanks with NA in character variable
body: <p>I'm recoding a selection of character variables, but keep getting an error message when trying to replace blanks with <code>NA</code>:</p>
  <pre><code>df &lt;- df %&gt;% mutate_at(vars(c(&quot;gender_1&quot;, &quot;gender_2&quot;, &quot;a_gender&quot;)),
                         funs(recode(., &quot;M&quot; = &quot;Male&quot;,
                                     &quot;F&quot; = &quot;Female&quot;,
                                     &quot;&quot; = NA_character_)))
  </code></pre>
  <pre><code>Error: attempt to use zero-length variable name
  </code></pre>
  <p>Can anyone spot my mistake? I'm sure it's something very obvious...</p>
  <p><strong>EDIT</strong>: code to generate a dataset similar to the one I'm grappling with:</p>
  <pre><code>gender_1 &lt;- as.character(c('F', '', 'F', 'M'))
  gender_2 &lt;- as.character(c('', 'M', 'F', 'M'))
  a_gender &lt;- as.character(c('', '', 'F', ''))
  df &lt;- data.frame(gender_1, gender_2, a_gender)
  </code></pre>