title: How to remove rows that meet certain certain criteria in R
body: <p>I have data from simulations of a population model where I have multiple replicates(run_num) with an unequal number of time steps in each run where I measure outputs of length and eggs (phys_length &amp; no_eggs). </p>
  
  <pre><code>&gt; head(params)
    run_num time_step phys_length no_eggs
  1       1         0 0.000000000       0
  2       1         1 0.008209734       0
  3       1         2 0.016332967       0
  4       1         3 0.024238314       0
  5       1         4 0.031594308       0
  6       1         5 0.033077672       0
  
  &gt; tail(params)
         run_num time_step phys_length no_eggs
  607395      49     13728    15.04109     727
  607396      49     13729    15.04111     727
  607397      49     13730    15.04112     727
  607398      49     13731    15.04113     727
  607399      49     13732    15.04114     727
  607400      49     13733    15.04115     727
  &gt; 
  
  
  </code></pre>
  
  <p>None of the the runs produce eggs in the early time steps (non-mature individuals), but some never begin to produce eggs. I want to find all the instances where the individual (run) never begins to produce eggs and remove that entire run from the dataframe.  My solution is to find the max time_step for each run and if no_eggs=0 remove that entire run. </p>
  
  <p>I'm an R newbie and have no idea where to begin to actually instruct R to do that. I'm thinking a for loop, but I get stuck when trying to figure out how to tell R to only look at the max time_step in each run. Then how to remove all rows that have that run_number.</p>
  
  <p>This is what I have so far, but I'm not sure if I am on the right track, since I've never worked with for-loops before now. </p>
  
  <pre><code>for (val in params$run_num)) {
    if(no_eggs   )
  }
  </code></pre>
  
  <p>Any ideas on how to do this are appreciated.  </p>