diff()函数的使用

1.diff():返回略微迭代(lagged)的或滞后的不同(iterated diferences)。

> x<-cumsum(cumsum(1:10))
> x
 [1]   1   4  10  20  35  56  84 120 165 220
> diff(x,differances=2)
[1]  3  6 10 15 21 28 36 45 55
> diff(.leap.seconds)
Time differences in days
 [1]  184  365  365  365  366  365  365  365  547  365  365  731  914  731  365  547
[17]  365  365  549  547  549 2557 1096 1277






















原文地址:https://www.cnblogs.com/wangshenwen/p/3235874.html