Keep value if not in case_when statement
<p>My data looks like this:</p>

<pre><code>df &lt;- expand.grid(grade = c("A", 1, "B", 2, 3, "C"), value = c(0, 1))
</code></pre>

<p>When I try to replace the <code>A</code>, <code>B</code>, and <code>C</code>s in a <code>case_when</code> statement, the non-replaced values go to <code>NA</code>... I want them to stay! </p>

<p>Attempt:</p>

<pre><code>library(dplyr)
df_new &lt;- df %&gt;% 
mutate(grade = case_when(
.$grade == "A" ~ 1,
.$grade == "B" ~ 2,
.$grade == "C" ~ 3))
</code></pre>

<p>Desired output:</p>

<pre><code>df &lt;- data.frame(grade = c(rep(1, 4), rep(2, 4), rep(3, 4)), value = rep(c(0, 1), 6))
</code></pre>

<p>Note** Looking for <code>case_when</code> solution NOT <code>ifelse</code> solution.</p>