title: How to dichotomize categorical variables into a new variable with 1s and 0s but maintain NAs?
body: <p>I am trying to create a new variable within my data frame to encapsulate questions with two categorical answers. I would like to be able to convert these to 1s and 0s. </p>
  
  <p>I've been using the <code>ifelse()</code> function but I feel like it inherently wants to convert <code>NA</code> values into 0s in my case. Adding the <code>na.rm=TRUE</code> argument onto the end gives me an error.</p>
  
  <pre><code>data$Knowledge=ifelse(data$Variable=="Yes",1,0, na.rm=TRUE)
  </code></pre>
  
  <blockquote>
    <p>Error in ifelse(data$Sabe.qué.trata.la.Ley.No.26378..Convención.sobre.los.Derechos.de.las.personas.con.discapacidad..sobre.las.personas.Sordas.o.hipoacúsicas. ==  : 
      unused argument (na.rm = TRUE)</p>
  </blockquote>