title: Create a group number for each consecutive sequence
body: <p>I have the data.frame below. I want to add a column 'g' that classifies my data according to consecutive sequences in column <code>h_no</code>. That is, the first sequence of h_no <code>1, 2, 3, 4</code> is group 1, the second series of <code>h_no</code> (1 to 7) is group 2, and so on, as indicated in the last column 'g'.</p>
  <pre><code>h_no   h_freq    h_freqsq g
  1     0.09091 0.008264628 1
  2     0.00000 0.000000000 1
  3     0.04545 0.002065702 1
  4     0.00000 0.000000000 1  
  1     0.13636 0.018594050 2
  2     0.00000 0.000000000 2
  3     0.00000 0.000000000 2
  4     0.04545 0.002065702 2
  5     0.31818 0.101238512 2
  6     0.00000 0.000000000 2
  7     0.50000 0.250000000 2 
  1     0.13636 0.018594050 3 
  2     0.09091 0.008264628 3
  3     0.40909 0.167354628 3
  4     0.04545 0.002065702 3
  </code></pre>