title: Replace values in R, "Yes" to 1 and "No" to 0
body: <p>I am working with weatherAUS dataset that is avaiable in the R libraries. I am trying to replace "Yes" to 1 and "No" to 0 in the RainTomorrow column.</p>
  
  <p>I wrote this but it doesn't seem to work:</p>
  
  <pre><code>weather4$RainTomorrow[weather4$RainTomorrow=="Yes"]&lt;-1 
  </code></pre>
  
  <p>I just says:</p>
  
  <blockquote>
    <p>Warning message: In <code>[&lt;-.factor</code>(<code>*tmp*</code>, weather4$RainTomorrow ==
    "Yes", value = c(NA,  :   invalid factor level, NA generated</p>
  </blockquote>
  
  <p>What does it mean and what should I do? I reckon I should use as.numeric or as.factor somewhere but I don't know how really.</p>