title: Combine date and hourly values in columns into timeseries (and reverse) in R
body: <p>I have some CSV data in the format:</p>
  
  <pre><code>date, total, avg, hour00, hour01, ... hour23
  </code></pre>
  
  <p>This I would like to expand into a time series in the format:</p>
  
  <pre><code>date-time(date + hourXX), (value of hourXX)
  </code></pre>
  
  <p>Example input:</p>
  
  <pre><code>      date, total, avg, hour00, hour01, hour02, hour03, ..., hour23
  2013-01-27,   240,  10,      5,     15,     20,      0, ...,     14
  2013-01-28,   305,  15,      9,     18,     17,     12, ...,     16
  </code></pre>
  
  <p>Example output (data.frame object):</p>
  
  <pre><code>       date-time, hourXX
  2013-01-27 00:00,      5
  2013-01-27 01:00,     15
  2013-01-27 02:00,     20
  2013-01-27 03:00,      0
  ...
  2013-01-27 23:00,     14
  2013-01-28 00:00,     15
  ...
  </code></pre>
  
  <p>So each value in column hour00-hour23 corresponds to the sample taken at date+hourXX.</p>
  
  <p>I know how to do this in sql, where I would make 24 UNION ALL, each selecting a column, but is there a 'smart' way of doing this in <strong>R</strong> (or maybe some experts out there who even knows a better way of doing this in sql).</p>
  
  <p>As a bonus question, is there a way of doing this in reverse (taking a time series and converting it into hour00-hour23 format)?</p>