How do I create a new column based on multiple conditions from multiple columns?
<p>I'm trying add a new column to a data frame based on several conditions from other columns.  I have the following data:</p>

<pre><code>&gt; commute &lt;- c("walk", "bike", "subway", "drive", "ferry", "walk", "bike", "subway", "drive", "ferry", "walk", "bike", "subway", "drive", "ferry")
&gt; kids &lt;- c("Yes", "Yes", "No", "No", "Yes", "Yes", "No", "No", "Yes", "Yes", "No", "No", "Yes", "No", "Yes")
&gt; distance &lt;- c(1, 12, 5, 25, 7, 2, "", 8, 19, 7, "", 4, 16, 12, 7)
&gt; 
&gt; df = data.frame(commute, kids, distance)
&gt; df
   commute kids distance
1     walk  Yes        1
2     bike  Yes       12
3   subway   No        5
4    drive   No       25
5    ferry  Yes        7
6     walk  Yes        2
7     bike   No         
8   subway   No        8
9    drive  Yes       19
10   ferry  Yes        7
11    walk   No         
12    bike   No        4
13  subway  Yes       16
14   drive   No       12
15   ferry  Yes        7
</code></pre>

<p>If the following three conditions are met:</p>

<pre><code>commute = walk OR bike OR subway OR ferry
AND
kids = Yes
AND
distance is less than 10
</code></pre>

<p>Then I'd like a new column called get.flyer to equal "Yes". The final data frame should look like this:</p>

<pre><code>   commute kids distance get.flyer
1     walk  Yes        1       Yes
2     bike  Yes       12       Yes
3   subway   No        5          
4    drive   No       25          
5    ferry  Yes        7       Yes
6     walk  Yes        2       Yes
7     bike   No                   
8   subway   No        8          
9    drive  Yes       19          
10   ferry  Yes        7       Yes
11    walk   No                   
12    bike   No        4          
13  subway  Yes       16       Yes
14   drive   No       12          
15   ferry  Yes        7       Yes
</code></pre>