title: How to count how many elements satisfy a condition in an idiomatic way?
body: <p>Having this data:</p>
  
  <pre><code>&gt; data
   [1] 1290603356 1290603360 1290603350 1290603344 1290603340 1290603373
   [7] 1290603354 1290603359 1290603345 1290603363 1290603357 1290603354
  [13] 1290603364 1290603349 1290603352 1290603365 1290603349 1290603343
  [19] 1290603339 1290603343
  &gt; offsets &lt;- c(0, 0.5,1,2,4,8,24,4*24,7*24) * 3600)
  [1]   1800   3600   7200  14400  28800  86400 345600 604800
  &gt; myoffsets &lt;- min(data)+offsets
  </code></pre>
  
  <p>being, a list of UNIX epochs and a list of offsets (0.5 hours, 1h, 2h, 4h...)
  I want to be able to graph how many of the epochs are &lt;= than the min(data) + offset</p>
  
  <p>In this example it would be</p>
  
  <pre><code>1 20 20 20 20 20 20 20
  </code></pre>
  
  <p>I have found how to do this with a for loop:</p>
  
  <pre><code>for(i in c(1:length(myoffsets))) myres$x[i] &lt;- length(data[data &lt;= myoffsets[i]])
  </code></pre>
  
  <p>But I'm sure there's a more idiomatic way if doing this that is not as convoluted?</p>