cumall.: Cumulative versions of any, all, and mean

Description Usage Arguments Examples

View source: R/cumulative.R

Description

cumall.(), cumany.(), and cummean.() to work alongside base cumsum()

Usage

1
2
3
4
5

Arguments

x

For cumall.() and cumany.() a logical vector. For cummean.() and integer or numeric vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
x <- c(1, 3, 5, 2, 2)
cummean.(x)

# `cumall()` and `cumany()` return logicals
cumall.(x < 5)
cumany.(x == 3)

# `cumall()` vs. `cumany()
df <- data.table(
  date = as.Date("2020-01-01") + 0:6,
  balance = c(100, 50, 25, -25, -50, 30, 120)
)

# all rows after first overdraft
df %>% filter.(cumany.(balance < 0))

# all rows until first overdraft
df %>% filter.(cumall.(!(balance < 0)))

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.