title: Collapse consecutive runs of numbers to a string of ranges
body: <p>Let's say I have the following vector of numbers:</p>
  
  <pre><code>vec = c(1, 2, 3, 5, 7, 8, 9, 10, 11, 12)
  </code></pre>
  
  <p>I'm looking for a function that will create a string summarizing the list of numbers the way a human would. That is, each run of consecutive numbers (here <code>1, 2, 3</code> and <code>7, 8, 9, 10, 11, 12</code>) is collapsed into its start and end value:</p>
  
  <pre><code>"1-3, 5, 7-12"
  </code></pre>
  
  <p>How can I do this in R?</p>