get_diff: Compute the difference of values in vector

Description Usage Arguments Value Author(s) See Also Examples

Description

Compute the difference of values in vector

Usage

1

Arguments

x

numeric vector

Value

numeric vector

Author(s)

Thomas P. Harte

See Also

numeric, diff

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  get_diff(c(NA))
  get_diff(c(NA, NA))
  get_diff(c(NaN, NA))
  get_diff(c(NaN, 1, 1.1))
  get_diff(c(1, +Inf, 1.1))

  dates<- seq(as.Date("2011-01-01"), by=1, len=6)
  z<- zoo(c(NA, 1, 2, 3, 0, 0), order.by=dates)

  zoo::rollapply(z, 2, get_diff, align="right")
  # 2011-01-02 2011-01-03 2011-01-04 2011-01-05 2011-01-06
  #	  NA        1.0        1.0       -3.0         0

tharte/tutils documentation built on Feb. 11, 2020, 9:17 a.m.