title: R ifelse to replace values in a column
body: <p>I have a column in my dataframe as follows: </p>
  
  <pre><code>Private
  Private
  Private
   ?
  Private
  </code></pre>
  
  <p>I want to replace this " ?" with Private. I have a solution as follows:</p>
  
  <pre><code># Only replacing ? with Private 
  df$var &lt;- ifelse(df$var == " ?", " Private", df$var)
  </code></pre>
  
  <p>However when I print out the <code>df$var</code> column after the ifelse statement, these values don't seem correct. This is what I got: </p>
  
  <pre><code>3
  3
  3
  Private
  3
  </code></pre>
  
  <p>I don't know what went wrong here. </p>