Skip to content

Commit

Permalink
Merge pull request #62 from ropensci/fix/warning-merge-on
Browse files Browse the repository at this point in the history
Fix/warnings from merge args
  • Loading branch information
robitalec committed Apr 14, 2024
2 parents 625d6d3 + f7d4b7b commit bab6163
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions R/randomizations.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,15 @@ randomizations <- function(DT = NULL,

if (type == 'daily') {
if (is.null(splitBy)) {
splitBy <- c('jul', 'iteration')
splitBy <- c('jul', 'iteration', 'observed')
} else {
splitBy <- c('jul', 'iteration', splitBy)
splitBy <- c('jul', 'iteration', 'observed', splitBy)
}


idDays[, randomID := .SD[sample(.N, size = .N)], by = c(splitBy), .SDcols = id]
idDays[(observed), randomID := .SD[[1]], .SDcols = id]

return(merge(repDT, idDays, on = splitBy, all = TRUE))
return(merge(repDT, idDays, by = c(splitBy, id), all = TRUE))

} else if (type == 'trajectory') {
if (is.null(splitBy)) {
Expand All @@ -285,7 +284,7 @@ randomizations <- function(DT = NULL,
merged <- merge(
x = repDT,
y = idDays,
on = c('jul', splitBy),
by = c('jul', splitBy),
all = TRUE
)

Expand Down

0 comments on commit bab6163

Please sign in to comment.