I have a matrix that kind of looks like this
M = matrix( 1:12, ncol=1)
I now would like to fetch the difference between the rows. So the value of row 2 - row 1.
I could write a loop that subtracts the element of that row and the element of the row -1 but something tells me there's a more efficient way.
Any thoughts on how I can do this better?