-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfixRCranlogs.R
30 lines (25 loc) · 1022 Bytes
/
fixRCranlogs.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#' Amend "duplicated" R application download counts in cranlogs::cranDownloads().
#'
#' Twenty days between 2023-09-13 through 2023-10-02.
#' @param out Object. An R list.
#' @note See getCorrectLogs().
#' @return An R list.
#' @noRd
fixRCranlogs <- function(out) {
dates <- seq.Date(as.Date("2023-09-12"), as.Date("2023-10-02"), by = "days")
rlog.err <- dates[!dates %in% "2023-09-28"] # 1:1
sep30 <- rlog.err %in% "2023-09-30"
rlog.2x.err <- out$cranlogs.data$date %in% rlog.err[!sep30] # 2:1
rlog.3x.err <- out$cranlogs.data$date %in% rlog.err[sep30] # 3:1
if (any(rlog.3x.err)) {
count.fix <- out$cranlogs.data[rlog.3x.err, ]$count / 3L
out$cranlogs.data[rlog.3x.err, "count"] <- count.fix
}
if (any(rlog.2x.err)) {
count.fix <- out$cranlogs.data[rlog.2x.err, ]$count / 2L
out$cranlogs.data[rlog.2x.err, "count"] <- count.fix
}
recalc <- tapply(out$cranlogs.data$count, out$cranlogs.data$platform, cumsum)
out$cranlogs.data$cumulative <- unlist(recalc)
out
}