title: Draw trend lines on a scatterplot with datetime variable
body: <p>I have a data frame of almost 1600 observations with this structure:</p>
  
  <pre><code>head(df)
  
  Start_Time Duration
  1 2014-09-18 10:01:00   4 mins
  2 2014-09-18 08:01:00  41 mins
  3 2014-09-18 08:01:00  22 mins
  4 2014-09-18 08:01:00  41 mins
  5 2014-09-18 08:01:00  60 mins
  6 2014-09-18 07:02:00  17 mins
  </code></pre>
  
  <p>I have plotted my data with this function:</p>
  
  <pre><code>plot(df$Start_Time,as.numeric(df$Duration), ylab = "Duration", xlab = "Date", ylim = c(0,450))
  </code></pre>
  
  <p>Since the data frame contains several tens of observations per day, I would like to draw a trend line in order to make it easier to read the data visually.</p>
  
  <p>I tried this code:</p>
  
  <pre><code>fit &lt;- glm(df$Start_Time~df$Duration)
  co &lt;- coef(fit)
  abline(fit, col="red", lwd=2)
  </code></pre>
  
  <p>but I get this error:</p>
  
  <pre><code>Error in model.frame.default(formula = df$Start_Time ~ df$Duration,  : 
  invalid type (list) for variable 'df$Start_Time'
  </code></pre>
  
  <p>I got the same error with this code:</p>
  
  <pre><code>abline(lm(df$Start_Time ~ df$Duration))
  </code></pre>
  
  <p>From reading the error messages, I suppose that those functions can't hande non-numeric values.
  I tried this and got no error, but the line wasn't displayed on my graph:</p>
  
  <pre><code>fit &lt;- glm(as.numeric(df$Start_Time)~df$Duration)
  co &lt;- coef(fit)
  abline(fit, col="red", lwd=2)
  </code></pre>
  
  <p>What is the correct way of drawing trend lines / regression lines when one of the variables is in the datetime format?</p>
  
  <p>NOTE: what follows is the result of str(df)</p>
  
  <pre><code>str(df)
  'data.frame':   4121 obs. of  2 variables:
  $ Start_Time: POSIXlt, format: "2014-09-18 10:01:00" "2014-09-18 08:01:00" "2014-09-18 08:01:00" "2014-09-18 08:01:00" ...
  $ Duration  :Class 'difftime'  atomic [1:4121] 4 41 22 41 60 17 17 2 3 3 ...   .. ..- attr(*, "units")= chr "mins"
  </code></pre>