From 635776363b609d7d966e0efb7812334b0bed353c Mon Sep 17 00:00:00 2001 From: Admin_EFridgei Date: Wed, 20 Dec 2023 12:35:26 -0500 Subject: [PATCH 1/3] filter before join --- R/PopulationSettings.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/PopulationSettings.R b/R/PopulationSettings.R index b532a8df9..88422ee75 100644 --- a/R/PopulationSettings.R +++ b/R/PopulationSettings.R @@ -259,9 +259,9 @@ createStudyPopulation <- function( # get the outcomes during TAR - outcomeTAR <- population %>% - dplyr::inner_join(plpData$outcomes, by ='rowId') %>% - dplyr::filter(.data$outcomeId == get('oId')) %>% + outcomeTAR <- plpData$outcomes %>% + dplyr::filter(.data$outcomeId == get("oId")) %>% + dplyr::inner_join(population, by = "rowId") %>% dplyr::select("rowId", "daysToEvent", "tarStart", "tarEnd") %>% dplyr::filter(.data$daysToEvent >= .data$tarStart & .data$daysToEvent <= .data$tarEnd) From 8f8ccb8b63a92f9dc4b67e32602867b47a05ef09 Mon Sep 17 00:00:00 2001 From: Admin_EFridgei Date: Wed, 20 Dec 2023 14:47:23 -0500 Subject: [PATCH 2/3] filter cohort if existing population --- R/PopulationSettings.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/PopulationSettings.R b/R/PopulationSettings.R index 88422ee75..5804cfd50 100644 --- a/R/PopulationSettings.R +++ b/R/PopulationSettings.R @@ -215,6 +215,9 @@ createStudyPopulation <- function( if (is.null(population)) { population <- plpData$cohorts + } else { + population <- plpData$cohorts %>% + dplyr::filter(.data$rowId %in% (population %>% dplyr::pull(.data$rowId))) } # save the metadata (should have the ?targetId, outcomeId, plpDataSettings and population settings) From 5bb4c8adcdbeeb7425697416cc47717736b48510 Mon Sep 17 00:00:00 2001 From: egillax Date: Thu, 21 Dec 2023 13:46:14 +0100 Subject: [PATCH 3/3] another filter before join --- R/PopulationSettings.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/PopulationSettings.R b/R/PopulationSettings.R index 5804cfd50..098a784f7 100644 --- a/R/PopulationSettings.R +++ b/R/PopulationSettings.R @@ -334,9 +334,9 @@ createStudyPopulation <- function( ParallelLogger::logTrace("Removing subjects with prior outcomes (if any)") # get the outcomes during TAR - outcomeBefore <- population %>% - dplyr::inner_join(plpData$outcomes, by ='rowId') %>% + outcomeBefore <- plpData$outcomes %>% dplyr::filter(outcomeId == get('oId')) %>% + dplyr::inner_join(population, by = 'rowId') %>% dplyr::select("rowId", "daysToEvent", "tarStart") %>% dplyr::filter(.data$daysToEvent < .data$tarStart & .data$daysToEvent > -get('priorOutcomeLookback') )