title: Add column into a dataframe based on condition
body: <p>I have a dataframe that looks like this but with 20 levels.</p>
  
  <pre><code>df &lt;- data.frame(
      x = factor(c("alpha","beta","gamma","delta")),
      y = factor(c("alpha","beta","gamma","delta")),
      z = factor(c("alpha","beta","gamma","delta"))
  </code></pre>
  
  <p>I would like to create a column within a dataframe based on three other columns.</p>
  
  <pre><code>df$w&lt;-with(df,ifelse(df$z==df$x,df$y,df$x))
  </code></pre>
  
  <p>But it does not give back the content of the columns, just levels.</p>