Skip to contents

A streak is a run of days in a row with at least one contribution. The current streak is the one that reaches the day of the collection; it still runs when that day has no contribution yet, since the day is not over. Of two equally long streaks, the longest is the more recent.

Usage

streaks(contrib, today)

Arguments

contrib

The contributions, a data frame of date and count.

today

The day of the collection.

Value

A list of two streaks, current and longest, each a list of its first day start, its last day end and its length in days: NA, NA and 0 when there is none.

Examples

contrib <- data.frame(date = c("2026-11-28", "2026-11-29", "2026-12-01", "2026-12-02"),
                      count = c(3, 1, 2, 5))
str(rghcard:::streaks(contrib, as.Date("2026-12-03")))
#> List of 2
#>  $ current:List of 3
#>   ..$ start : Date[1:1], format: "2026-12-01"
#>   ..$ end   : Date[1:1], format: "2026-12-02"
#>   ..$ length: int 2
#>  $ longest:List of 3
#>   ..$ start : Date[1:1], format: "2026-12-01"
#>   ..$ end   : Date[1:1], format: "2026-12-02"
#>   ..$ length: int 2