title: Check for a match between a list of values and a column entry in R
body: <p>I have a dataset with a column <code>Disease</code> that contains string values. I also have a list of names with rare diseases <code>rare_disease</code>. </p>
  
  <p>I want to check, for each cell of the column <code>Disease</code>, whether it contains an element from the list <code>rare_disease</code> and if so, to create a new column in my dataframe and give the value 1 to that entry. </p>
  
  <p>I tried using the <code>ifelse</code> function, like so:</p>
  
  <pre><code>FinalData$RareDisease &lt;- ifelse(rare_disease %in% FinalData$Disease,1,0)
  </code></pre>
  
  <p>But I guess that checks whether the the corresponding rows in both variables are the same, so it throws an error. Instead, I want every cell of <code>Disease</code> to be checked against every single element of <code>rare_disease</code>, if that makes sense.</p>
  
  <p>I have also tried <code>match</code> and <code>is.element()</code> as suggested here <a href="https://stackoverflow.com/questions/1169248/test-if-a-vector-contains-a-given-element">Test if a vector contains a given element</a> but they don't work either.</p>