title: Error "Origin must be supplied" when using difftime + subtraction operator not working for different minutes
body: <p>I have a data frame of two columns "start" and "end" in <strong>HH:MM:SS</strong> format. </p>
  
  <p>I wanted to calculate duration between start and end using <strong>difftime</strong> function</p>
  
  <p>It always gives back this error: 
  Error in as.POSIXct.numeric(time1) : 'origin' must be supplied</p>
  
  <p>I read many posts but none seemed to work for me.</p>
  
  <p>Loading packages</p>
  
  <pre><code>library(dplyr)
  library(tidyverse)
  library(lubridate)
  </code></pre>
  
  <p>I removed hours to deal with minutes and seconds only</p>
  
  <pre><code>get_time &lt;- function(x){str_sub(x, start = -5) %&gt;%  ms()} 
  df &lt;- df %&gt;% mutate(start = get_time(start)) %&gt;%
    mutate(end = get_time(end))
  </code></pre>
  
  <p>Class of objects</p>
  
  <pre><code>class(df$start)
  gives: 
  [1] "Period"
  attr(,"package")
  [1] "lubridate"
  </code></pre>
  
  <pre><code>start                 end       
  
  26M 22S               26M 23S        
  26M 25S               26M 37S      
  29M 47S               30M 13S
  </code></pre>
  
  <p>I calculated duration using <strong>difftime</strong> function</p>
  
  <pre><code>df$duration &lt;- with(df, difftime(end, start, units="secs"))
  gives error:
  Error in as.POSIXct.numeric(time1) : 'origin' must be supplied
  </code></pre>
  
  <p>I used subtraction operator, it worked fine except for 3rd row when minutes are different, it gave wrong answer. </p>
  
  <pre><code>start                 end            duration
  
  26M 22S               26M 23S        1S
  26M 25S               26M 37S        12S
  29M 47S               30M 13S        1M -34S
  </code></pre>
  
  <p><em>Amendment</em></p>
  
  <p>The accepted response works perfectly fine, except that it returns an error:
  <strong>Error in mtx1[3, ] : incorrect number of dimensions</strong> whenever applied to the second two columns "start2" and "end2" that I have in the same data frame. </p>
  
  <p>sample from my df</p>
  
  <pre><code>df &lt;- structure(list(item = c("manatee", "manatee", "pile", "pile"), prestart = new("Period", .Data = c(22, 
  25, 41, 49), year = c(0, 0, 0, 0), month = c(0, 
  0, 0, 0), day = c(0, 0, 0, 0), hour = c(0, 0, 0, 
  0), minute = c(26, 26, 26, 26)), preend = new("Period", 
      .Data = c(23, 37, 48, 50), year = c(0, 0, 0, 0), month = c(0, 0, 0, 0), day = c(0, 0, 0, 0
      ), hour = c(0, 0, 0, 0), minute = c(26, 26, 26, 26)), poststart = new("Period", .Data = c(23, 41, 50, 
  54), year = c(0, 0, 0, 0), month = c(0, 0, 0, 0), day = c(0, 0, 0, 0), hour = c(0, 0, 0, 0), 
      minute = c(26, 26, 26, 26)), postend = new("Period", 
      .Data = c(37, 48, 52, 22), year = c(0, 0, 0, 0), month = c(0, 0, 0, 0), day = c(0, 0, 0, 0
      ), hour = c(0, 0, 0, 0), minute = c(26, 26, 26, 27))), row.names = c(NA, -6L), class = c("tbl_df", "tbl", 
  "data.frame"))
  </code></pre>
  
  <p>Organising data in minutes and seconds only (remove hours)</p>
  
  <pre><code>
  get_time &lt;- function(x){str_sub(x, start = -5) %&gt;%  ms()} 
  df &lt;- df %&gt;% mutate(prestart = get_time(prestart)) %&gt;%
    mutate(preend = get_time(preend)) %&gt;% 
    mutate(poststart = get_time(poststart)) %&gt;% 
    mutate(postend = get_time(postend))
  
  
  </code></pre>