title: Conditional Slicing of Rows in R
body: <p>I'm trying to isolate the rows of the last 9 instances a certain value occurrs.
  However, some values occur less than 9 times.
  Is it possible to ignore them and only slice those rows that fulfill the condition (which is: value occurs at least 9 times in the vector)?</p>
  <p>When I run the piece of code below, I get the following error:</p>
  <p>slice() expressions should return either all positive or all negative.</p>
  <pre><code>gtr&lt;-rdat2%&gt;%
      group_by(HomeTeam)%&gt;%
      arrange(rdat2$HsT,HomeTeam)%&gt;%
      slice((n()-8):n())
  </code></pre>
  <p>I was thinking of making an if-statement but don't know how to capture that the value must occur a certain number of times. Any help would be greatly appreciated.</p>