intervals: intervals

Description Usage Arguments Examples

View source: R/wranglers.R

Description

Function that takes a numeric vector and outputs the difference between each succsessive member. It also needs to know where to place a 0 - either at the end of the vector (matching each difference with where it left from) or at the beginning of the vector (matching each difference with where it goes to).

Usage

1
intervals(x, end_at_0 = TRUE, sub_0 = 0)

Arguments

x

a numeric vector (can be dates, etc)

end_at_0

decision on where to place the 0 to return vector of the same length. Defaults to TRUE, indicating the output matches with where the element is leaving from.

sub_0

What this places for the end_at_0 parameter. Defaults to 0

Examples

1
2
3
4
v <- c(1,2,3)
intervals(v)
intervals(v, FALSE)
intervals(v, TRUE, NA)

benwhicks/lakit documentation built on Sept. 28, 2019, 4:27 p.m.