title: How to convert decimal time to time format
body: <p>I would like to calculate the difference between two time-sets. I can do this, but I only get the difference in decimals and I would like to know how to convert them to format as in "Minutes:Second".</p>
  
  <p>So, I have the minutes and the seconds as characters:</p>
  
  <pre><code>video_begin &lt;- c("8:14", "4:47", "8:27", "4:59", "4:57", "7:51", "6:11", "5:30")
  video_end &lt;- c("39:08", "47:10", "49:51", "44:31", "39:41", "47:12", "40:13", "46:52")
  </code></pre>
  
  <p>I convert them into time values with as.POSIXct, make a df and add the difference as a third column, easy peasy...</p>
  
  <pre><code>video_begin &lt;- as.POSIXct(video_begin, format = "%M:%S")
  video_end &lt;- as.POSIXct(video_end, format = "%M:%S")
  video &lt;- data.frame(video_begin, video_end)
  video$video_duration &lt;- video_end - video_begin
  </code></pre>
  
  <p>And this is what I get for <code>video</code>:</p>
  
  <pre><code>  video_begin         video_end            video_duration
  1 2017-09-12 00:08:14 2017-09-12 00:39:08  30.90000 mins
  2 2017-09-12 00:04:47 2017-09-12 00:47:10  42.38333 mins
  3 2017-09-12 00:08:27 2017-09-12 00:49:51  41.40000 mins
  4 2017-09-12 00:04:59 2017-09-12 00:44:31  39.53333 mins
  5 2017-09-12 00:04:57 2017-09-12 00:39:41  34.73333 mins
  6 2017-09-12 00:07:51 2017-09-12 00:47:12  39.35000 mins
  7 2017-09-12 00:06:11 2017-09-12 00:40:13  34.03333 mins
  8 2017-09-12 00:05:30 2017-09-12 00:46:52  41.36667 mins
  </code></pre>
  
  <p>How do I change the format of <code>video$video_duration</code> from decimal to the same format as in <code>video$video_begin</code> and <code>video$video_end</code>: "Minutes:Seconds" (I don't care about day, month, year and hour)?</p>
  
  <p>I tried:</p>
  
  <pre><code>video$video_duration &lt;- as.POSIXct(video$video_duration, format = "%M:%S")
  </code></pre>
  
  <p>and</p>
  
  <pre><code>strptime(video$video_duration, format="%M:%S")
  </code></pre>
  
  <p>but nah...</p>
  
  <p>I found some answers but I'm not very satisfied with them: </p>
  
  <p><a href="https://stackoverflow.com/questions/14483629/how-convert-decimal-to-posix-time">How convert decimal to POSIX time</a></p>
  
  <p><a href="https://stackoverflow.com/questions/32829004/algorithm-to-convert-text-time-to-decimal-time">Algorithm to convert Text time to Decimal Time</a></p>
  
  <p>Isn't there a more... handy and easier way to do it?</p>
  
  <p>Thanks!</p>