title: calculating number of days between 2 columns of dates in data frame
body: <p>I have a data frame which has two columns of dates in the format yyyy/mm/dd.
  I am trying to calculate the number of days between these two dates for each observation within the data frame (and create a new variable with this number of days in it).</p>
  <p>So far I have tried using the answer given here:</p>
  <p><a href="https://stackoverflow.com/questions/5046708/calculate-the-number-of-weekdays-between-2-dates-in-r">Calculate the number of weekdays between 2 dates in R</a></p>
  <p>but editing the code so that it calculates number of total days rather than just the number of week days. This just came up with error saying:</p>
  <pre><code>Error in del/by : non-numeric argument to binary operator
  In addition: Warning message:
  In Ops.factor(to, from) : - not meaningful for factors
  </code></pre>
  <p>I have also attempted using this code:</p>
  <pre><code>finish &lt;- as.Date(survey$date, format=&quot;%yyyy/%mm/%dd&quot;)
  start &lt;- as.Date(survey$tx_start, format=&quot;%yyyy/%mm/%dd&quot;)
  date_diff&lt;-as.data.frame(finish-start)
  </code></pre>
  <p>with the plan of using &quot;cbind&quot; or something equivalent to combine the data frame &quot;days&quot; to my data frame &quot;survey&quot; which has data in it.</p>
  <p>Although this does not give me any errors, the observations within the &quot;finish&quot; and &quot;start&quot; objects are all &quot;NA_real_&quot;, and the date_diff data frame therefore has all the observations listed as NA.</p>
  <p>If someone could point me in the right direction that would be great! All the other question I have found do not seem to be dealing with dates within variables but as individual dates, and applying those techniques to variables hasn`t been working for me.</p>