title: Passing a list of (many) conditions to an if statement in R
body: <p>I have the following</p>
  
  <pre><code>Data &lt;- data.frame(
    randnum = sample(1:10),
    fruit   = sample(c("apple", "pear", "plum"), 10, replace = TRUE))
  </code></pre>
  
  <p>I want to create a new column called <code>Data$fruit.ID</code> based on fruit with the corresponding ID stored elsewhere, in this case another dataframe (<em>but only because I don't know any better!</em>):</p>
  
  <pre><code>fruit.ID.data &lt;- data.frame(
    fruit    = c("apple", "pear", "plum"),
    fruit.ID = c(123, 456, 789))
  
  &gt; fruit.ID.data
        fruit fruit.ID
  1     apple      123
  2      pear      456
  3 starfruit      789
  </code></pre>
  
  <p>There are many <code>fruits</code> and many <code>fruit.ID</code>'s so huge <code>if.else</code>, <code>else</code>, <code>else</code> is not a preferable option. </p>
  
  <p>How can I pass the fruit ID info the to the if statement?</p>
  
  <p><code>data$fruit.ID</code></p>