[R] difference along a vector
Marc Schwartz
marc_schwartz at me.com
Wed May 12 21:16:11 CEST 2010
On May 12, 2010, at 2:06 PM, Clark Johnston wrote:
>
> I was looking for a function which would take the difference along a vector?
>> a<-c(1,12,23,44,15,28,7,8,9,10)
> if I set the number difference to 3 would return
> 43
> 2
> 5
> -37
> -7
> -19
> 3
>
> or do I need to write my own function for this.
?diff
> diff(a, lag = 3)
[1] 43 3 5 -37 -7 -19 3
HTH,
Marc Schwartz
More information about the R-help
mailing list