Re: [R] using diff function with by function

2014-03-10 Thread Rui Barradas
Hello, Maybe you want by(tr$srv_dt, tr$Rmbr, diff, lag=1, difference=1) Can't you ?dput a data example? dput(head(tr, 30)) # paste the output of this in a post Hope this helps, Rui Barradas Em 10-03-2014 16:10, Mckinstry, Craig escreveu: I have been trying to process a data.frame (tr) o

[R] using diff function with by function

2014-03-10 Thread Mckinstry, Craig
I have been trying to process a data.frame (tr) on a grouping factor (Rmbr) using diff to find differences between srv_dt (a date) by Rmbr and keep getting the following error message > tmp <- by(tr,tr$Rmbr, diff, tr$srv_dt, lag=1, difference=1) Error in r[i1] - r[-length(r):-(length(r) - lag +