title: Convert Character column value to binary value in data frame
body: <p>I have a class column in my data frame which carries the value "Bad" &amp; "Good". I want to replace these string into 0 &amp; 1 respectively. </p>
  
  <p>I tried the following: </p>
  
  <pre><code> x = c("Bad", "Good", "Bad", "Bad", "Good")
  
  factor(x)
  
  factor(x, c(0, 1))
  </code></pre>
  
  <p>but, it converts the value in the dataset to <code>NA</code> </p>
  
  <pre><code>factor(x, c(0, 1))
  
  [1] &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;`
  Levels: 0 1`
  </code></pre>