Assigning a constant with mutate_each
<p>I would like to set all values in each of several columns to <code>NA</code>. Normally, if I would like to modify several columns using the same algorithm I would use <code>mutate_each</code> from dplyr. From an algorithmic standpoint, the function "x maps to null" seems perfectly well-defined, so I tried to do that. However, I got an error: <code>Error in make_call(x$expr, args) : Unknown inputs</code>. </p>

<p>Minimum reproducible example:</p>

<pre><code>sample &lt;- data.frame(a = seq(1, 3), b = seq(5, 7))

sample %&gt;% mutate(a = 1, b = 1)           # Works fine
sample %&gt;% mutate_each(funs(. - 1), a, b) # Works fine
sample %&gt;% mutate_each(funs(1), a, b)     # Blows up
sample %&gt;% mutate_each(funs(NA), a, b)    # Blows up
</code></pre>

<p>I also tried explicitly defining a function, eg</p>

<pre><code>mutate_each(funs(function(x) {NA}), Address, City, State, Zip)
</code></pre>

<p>This leads to a different error: <code>Error: Unsupported type CLOSXP for column "a"</code>. What is the right way to do this?</p>