Steven Sanderson notices the difference:
The
diff()
function in R calculates the differences between consecutive elements in a vector or a time series. It takes a single argument, which is the input vector, and returns a new vector with the differences. This function is particularly useful for analyzing the rate of change, identifying patterns, and detecting anomalies in your data.
Read on to see how you can use it, as well as some examples of usage.