title: How to create logical variable based on logical condition?
body: <p>I have a data frame with factor variables</p>
  
  <pre><code>&gt; a &lt;- c("a", "b", "c")
  &gt; b &lt;- c("c", "b", "a")
  &gt; df &lt;- as.data.frame(cbind(a,b))
  &gt; df$a &lt;- as.factor(df$a)
  &gt; df$b &lt;- as.factor(df$b)
  &gt; df
    a b
  1 a c
  2 b b
  3 c a
  </code></pre>
  
  <p>I create new logical variable based on the similarity of var a and var b.</p>
  
  <pre><code>&gt; df$result &lt;- isTRUE(df$a == df$b)
  </code></pre>
  
  <p>But I get the result:</p>
  
  <pre><code>&gt; df
    a b result
  1 a c  FALSE
  2 b b  FALSE
  3 c a  FALSE
  </code></pre>
  
  <p>When I expected</p>
  
  <pre><code>&gt; df
    a b result
    1 a c  FALSE
    2 b b  TRUE
    3 c a  FALSE
  </code></pre>
  
  <p>(I'm using factors to replicate my real data)</p>
  
  <p>What am I doing wrong? How can I achieve my goal of identifying similar variables? Thanks</p>