Skip to contents

Adds the rows of new to those of old and sorts them by the key of the table. A row with the key of an older one replaces it: the traffic of the current day is still counting when it is read, and the next collection brings the full day.

Usage

merge_history(old, new, name)

Arguments

old, new

The rows the history has, and the rows of a new collection.

name

The name of a table of the history, such as "repos" or "views".

Value

The table, a data frame.

Examples

old <- data.frame(repo = "rwf", date = c("2026-12-01", "2026-12-02"), count = c(45, 10),
                  uniques = c(9, 3))
new <- data.frame(repo = "rwf", date = c("2026-12-02", "2026-12-03"), count = c(38, 7),
                  uniques = c(8, 2))
rghcard:::merge_history(old, new, "views")
#>   repo       date count uniques
#> 1  rwf 2026-12-01    45       9
#> 2  rwf 2026-12-02    38       8
#> 3  rwf 2026-12-03     7       2