From 5cfecc80b62559dbfde843716c1f489052fdee4f Mon Sep 17 00:00:00 2001 From: "Alec L. Robitaille" Date: Sun, 14 Apr 2024 15:13:44 -0300 Subject: [PATCH 1/5] specify data.table merge --- R/edge_dist.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/edge_dist.R b/R/edge_dist.R index 7201ab12..f75a329d 100644 --- a/R/edge_dist.R +++ b/R/edge_dist.R @@ -226,7 +226,7 @@ edge_dist <- function(DT = NULL, if (fillNA) { - merge(edges, + data.table::merge.data.table(edges, unique(DT[, .SD, .SDcols = c(splitBy, id)]), by.x = c(splitBy, 'ID1'), by.y = c(splitBy, id), From b1e4d27f138c44f33f479b0e39d6da30265edd5b Mon Sep 17 00:00:00 2001 From: "Alec L. Robitaille" Date: Sun, 14 Apr 2024 15:47:49 -0300 Subject: [PATCH 2/5] add observed to merge --- R/randomizations.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/randomizations.R b/R/randomizations.R index 8e4019f6..219a13b4 100644 --- a/R/randomizations.R +++ b/R/randomizations.R @@ -262,9 +262,9 @@ 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) } From efbe8000989f712380ea3d5eb9d9b95f5c1f4aaa Mon Sep 17 00:00:00 2001 From: "Alec L. Robitaille" Date: Sun, 14 Apr 2024 15:48:11 -0300 Subject: [PATCH 3/5] add id to merge --- R/randomizations.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/randomizations.R b/R/randomizations.R index 219a13b4..591b7fdf 100644 --- a/R/randomizations.R +++ b/R/randomizations.R @@ -267,11 +267,10 @@ randomizations <- function(DT = NULL, 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)) { From e4d5ce8898e915b39344a6aadaf18415a38aaa3c Mon Sep 17 00:00:00 2001 From: "Alec L. Robitaille" Date: Sun, 14 Apr 2024 15:48:15 -0300 Subject: [PATCH 4/5] use by arg --- R/randomizations.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/randomizations.R b/R/randomizations.R index 591b7fdf..e1033402 100644 --- a/R/randomizations.R +++ b/R/randomizations.R @@ -284,7 +284,7 @@ randomizations <- function(DT = NULL, merged <- merge( x = repDT, y = idDays, - on = c('jul', splitBy), + by = c('jul', splitBy), all = TRUE ) From f7d4b7bba66f4ea4e2ef1faaf4e65856e8bb81b7 Mon Sep 17 00:00:00 2001 From: "Alec L. Robitaille" Date: Sun, 14 Apr 2024 15:48:34 -0300 Subject: [PATCH 5/5] revert specify data.table merge --- R/edge_dist.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/edge_dist.R b/R/edge_dist.R index f75a329d..7201ab12 100644 --- a/R/edge_dist.R +++ b/R/edge_dist.R @@ -226,7 +226,7 @@ edge_dist <- function(DT = NULL, if (fillNA) { - data.table::merge.data.table(edges, + merge(edges, unique(DT[, .SD, .SDcols = c(splitBy, id)]), by.x = c(splitBy, 'ID1'), by.y = c(splitBy, id),