title: ifelse returns unexpected values
body: <p>Basically, I would like to create a new column based on an existing column. I want the new column to be changed only if it meets some conditions.</p>
  
  <p>I tried both ways below, but either one worked - it returned a numerical value instead of the value of the existing column for the FALSE condition. I read some posts indicating that ifelse removes the attributes of the column, which could causes the issue.</p>
  
  <p>Can someone help me? Thanks!</p>
  
  <p>BTW, it works fine if the existing column is numerical. </p>
  
  <pre><code>attach(iris)
  library(dplyr)
  
  # Approach 1
  d1 = iris %&gt;%
    mutate(s = ifelse(Species == "versicolor", "ver", Species))
  
  View(d1)
  
  # Approach 2
  d2=iris
  d2$s = ifelse(d2$Species == "versicolor", "ver", d2$Species)
  View(d2)
  </code></pre>