title: Loops and counting in R
body: <p>I want to count how many times the numbers in the data set reaches a limt (let it be 8 and -8) after it returned to 0
  in the attachment you can see a graph that explains my question better.
  so with this set of data it should be 6 times. can you please tell me how can I code it in R, or which functions should I read in order to do it my self.</p>
  
  <p>Data set:<a href="https://i.stack.imgur.com/88eVe.jpg" rel="nofollow noreferrer">enter image description here</a>
  {1
  0
  -8
  -1
  5
  3
  0
  -9
  -9
  -8
  0
  7
  -6
  4
  -4
  5
  -5
  0
  8
  -6
  8
  -2
  8
  0
  2
  7
  6
  0
  -8
  -8
  }</p>