title: How to add unique IDs for aligned sequences of sequential numbers?
body: <p>I have a data table of integer coordinates that align between two groups labelled A and B. For example:</p>
  
  <pre><code>dt_long &lt;- data.table(LABEL_A = c(rep("A", 20), rep("A", 15), rep ("A", 10), rep ("A", 15), rep ("A", 10)),
               SEQ_A = c(11:30, 61:75, 76:85, 86:100, 110:119),
               LABEL_B= c(rep("C", 20), rep("D", 15), rep("F", 10), rep("G",15), rep("D", 10)),
               SEQ_B = c(1:20, 25:11, 16:25, 15:1, 1:5, 8:12))
  </code></pre>
  
  <p>How can I add an ID column to this data.table with a unique id for each of the continuous aligned sequences? Each aligned sequence needs a separate ID if either SEQ_A or SEQ_B are not sequentially continuous, or if they belong to a different group (ie LABEL). For example:</p>
  
  <pre><code>    dt_long_ID &lt;- data.table(LABEL_A = c(rep("A", 20), rep("A", 15), rep ("A", 10), rep ("A", 15), rep ("A", 10)),
               SEQ_A = c(11:30, 61:75, 76:85, 86:100, 110:119),
               LABEL_B= c(rep("C", 20), rep("D", 15), rep("F", 10), rep("G",15), rep("D", 10)),
               SEQ_B = c(1:20, 25:11, 16:25, 15:1, 1:5, 8:12),
                    ID = c(rep(1, 20), rep(2, 15), rep(3, 10), rep(4, 15), rep(5, 5), rep(6, 5) ))
  </code></pre>