I am new to R and stuck in getting the difference between two non consecutive rows. My Data frame looks like:
       Column 1 | Column 2
  Row1    1     |   5
  Row2    3     |   6
  Row3    8     |   10
  Row4    6     |   1
  Row5   28     |   5
  Row6    7     |   4
I need to find the difference between Row1 and Row4, Row2 and Row5, Row3 and Row6 and so on. I have done this using For loop by giving the intervals but, its taking lots of time as there are huge number of rows.
Is there any other way to do it?
difffunction withlagargument. - user2100721Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : non-numeric argument to binary operator. - Ashish