Re: [R] difference between successive values

2016-03-05 Thread Jim Lemon
Hi catalin, I think what you are trying to do is to retrieve the original observations from the cumulated values. In that case Olivier's suggestion will do what you want: c(x[1],diff(x)) Jim On Sat, Mar 5, 2016 at 1:59 AM, catalin roibu wrote: > I mean the first row

Re: [R] difference between successive values

2016-03-04 Thread catalin roibu
I mean the first row value În Vin, 4 mar. 2016, 16:15 Jeff Newmiller, a scris: > "Keep the first values" is imprecise, but mixing an absolute value with a > bunch of differences doesn't usually work out well. I frequently choose > among > > x <- sample( 10 ) > dxright

Re: [R] difference between successive values

2016-03-04 Thread Jeff Newmiller
"Keep the first values" is imprecise, but mixing an absolute value with a bunch of differences doesn't usually work out well. I frequently choose among x <- sample( 10 ) dxright <- c( 0, diff(x) ) dxleft <- c( diff(x), 0 ) for calculation purposes depending on my needs. -- Sent from my

Re: [R] difference between successive values

2016-03-04 Thread Olivier Crouzet
Hi, (1) You should provide a minimal working example; (2) But anyway, does... x = sample(10) c(x[1],diff(x)) ... do what you want? Olivier. On Fri, 4 Mar 2016 13:22:07 +0200 catalin roibu wrote: > Dear all! > > I want to calculate difference between successive

[R] difference between successive values

2016-03-04 Thread catalin roibu
Dear all! I want to calculate difference between successive values (cumulative values) with R. I used diff function, but I want to keep the first values. Please help me to solve this problem! Thank you! Best regards! CR -- - - Catalin-Constantin ROIBU ​ Lecturer PhD, Forestry engineer