I know this answer must be out there, but I can\'t figure out how to word the question.
I\'d like to calculate the differences between values in my data.frame.
There are many different ways to do this, but here's one:
f[, "diff"] <- c(NA, diff(f$value))
More generally, if you want to refer to relative rows, you can use lag() or do it directly with indexes:
lag()
f[-1,"diff"] <- f[-1, "value"] - f[-nrow(f), "value"]