[R] difference between successive values
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Fri Mar 4 15:12:54 CET 2016
"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 phone. Please excuse my brevity.
On March 4, 2016 3:28:08 AM PST, Olivier Crouzet <olivier.crouzet at univ-nantes.fr> wrote:
>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 <catalinroibu at gmail.com> wrote:
>
>> 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
>> Forestry Faculty of Suceava
>> Str. Universitatii no. 13, Suceava, 720229, Romania
>> office phone +4 0230 52 29 78, ext. 531
>> mobile phone +4 0745 53 18 01
>> FAX: +4 0230 52 16 64
>> silvic.usv.ro <http://www.usv.ro/>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
>--
> Olivier Crouzet, PhD
> Laboratoire de Linguistique de Nantes -- UMR6310
> CNRS / Université de Nantes
> Chemin de la Censive du Tertre -- BP 81227
> 44312 Nantes cedex 3
> France
>
> http://www.lling.univ-nantes.fr/
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.
[[alternative HTML version deleted]]
More information about the R-help
mailing list