I'm trying to use diff() function to calculate the difference between subsequent column values. When I executed below code it gives an error that replacement has 249513 rows, data has 249514. I appreciate the reason for the error, however, I'd like to understand how to overcome this in an efficient manner. All inputs welcome.
data[,"diff_in_peak"] <- diff(data$peak)