Dear R-helpers, I have a dataframe with several columns, one of which is called LENGTH.
I would like to make a new column called DIFF containing the value of LENGTH minus LENGTH in the previous row, like this: ID LENGTH DIFF 1 1 10 NA 2 2 15 5 3 3 20 5 4 4 12 -8 5 5 18 6 I'd like to think there are "relative subscripts" in R but I can't find any reference to such a thing. Any help solving this problem would be much appreciated, thanks! Mark Na ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.