title: Convert factor into logical datatype
body: <p>I have a two levels factor in my data that I want to convert to logical</p>
  
  <pre><code>a &lt;- str(df$y)
  a
  Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
  </code></pre>
  
  <p>I use <code>as.logical(df$y)</code> to convert them into logical. However, the data turn into <code>NA</code> </p>
  
  <pre><code>summary(a)
  
        Mode    NA's 
      logical  500000
  </code></pre>
  
  <p>At which point do I fail to convert the data? </p>