title: Recode subset of variables using case when in R
body: <p>I am trying to recode some survey data in R. Here is some data similar to what I actually have.</p>
  <pre><code>df &lt;- data.frame(
    A = rep(&quot;Y&quot;,5),
    B=seq(as.POSIXct(&quot;2014-01-13&quot;), as.POSIXct(&quot;2014-01-17&quot;), by=&quot;days&quot;),
    C = c(&quot;Neither agree nor disagree&quot;,
          &quot;Somewhat agree&quot;,
          &quot;Somewhat disagree&quot;,
          &quot;Strongly agree&quot;,
          &quot;Strongly disagree&quot;),
    D=c(&quot;Neither agree nor disagree&quot;,
           &quot;Somewhat agree&quot;,
           &quot;Somewhat disagree&quot;,
           &quot;Strongly agree&quot;,
           &quot;Strongly disagree&quot;)
  )
  
  
  
  </code></pre>
  <p>I looked up some other posts and wrote the code below:</p>
  <pre><code>init2&lt;-df %&gt;%
    mutate_at(vars(c(1:4)), function(x) case_when( x == &quot;Neither agree nor disagree&quot; ~ 3, 
                                       x == &quot;Somewhat agree&quot; ~ 4, 
                                       x == &quot;Somewhat disagree&quot;~ 2,
                                       x== &quot;Strongly agree&quot;~ 5,
                                       x== &quot;Strongly disaagree&quot;~ 1
                                       
                                       ))
  
  </code></pre>
  <p>But this throws the error</p>
  <pre><code>Error: Problem with `mutate()` column `B`.
  i `B = (function (x) ...`.
  x character string is not in a standard unambiguous format
  
  Run `rlang::last_error()` to see where the error occurred. 
  </code></pre>
  <p>My input dates are POSIXct. SHould I change their format? What is the fix for this issue? Thanks.</p>