title: R how can I calculate difference between rows in a data frame
body: <p>Here is a simple example of my problem:</p>
  
  <pre><code>&gt; df &lt;- data.frame(ID=1:10,Score=4*10:1)
  &gt; df
         ID Score
      1   1    40
      2   2    36
      3   3    32
      4   4    28
      5   5    24
      6   6    20
      7   7    16
      8   8    12
      9   9     8
      10 10     4
      &gt; diff(df)
  
  Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : 
    non-numeric argument to binary operator
  </code></pre>
  
  <p>Can anyone tell me why this error occurs?</p>