title: How to compare many variables to one in r with ifelse?
body: <p>I'm trying to compare many variables to one (i.e. flag values in columns 1 through 5 smaller than column 6). I could do an ifelse like: want=ifelse(coll1 lt coll6 |coll2 lt coll6 | coll3 lt coll6...etc. ... 1, 0) but this is too long as I have hundreds of columns. Also, many columns have NA and they are formatted as POSIXct dates. Anyone know?</p>
  
  <p>Thanks!</p>
  
  <p>Want:</p>
  
  <pre><code>df&lt;-data.frame(col1=c("2000-01-06", "2000-01-07", "2000-01-04", "2000-01-07", NA, "2000-01-03", NA),
                 col2=c("2000-01-07", "2000-01-05", NA, NA, NA, NA,NA),
                 col3=c("2000-01-09", "2000-01-05", NA, NA, NA, NA, NA),
                 col4=c("2000-01-10", "2000-01-05", NA, "2000-01-07", "2000-01-08", NA, NA),
                 col5=c("2000-01-08", "2000-01-05", NA, NA, NA, NA, NA),
                 col6=c("2000-01-06", "2000-01-07", "2000-01-05", "2000-01-06", "2000-01-08", "2000-01-09", "2000-01-08"),
                 want=c(0, 1, 1, 0,0, 1, NA))
  
  
          col1       col2       col3       col4       col5       col6 want
  1 2000-01-06 2000-01-07 2000-01-09 2000-01-10 2000-01-08 2000-01-06    0
  2 2000-01-07 2000-01-05 2000-01-05 2000-01-05 2000-01-05 2000-01-07    1
  3 2000-01-04       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt; 2000-01-05    1
  4 2000-01-07       &lt;NA&gt;       &lt;NA&gt; 2000-01-07       &lt;NA&gt; 2000-01-06    0
  5       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt; 2000-01-08       &lt;NA&gt; 2000-01-08    0
  6 2000-01-03       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt; 2000-01-09    1
  7       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt;       &lt;NA&gt; 2000-01-08   NA
  
  </code></pre>