Skip to content

Commit

Permalink
Merge pull request #419 from OHDSI/faster_population
Browse files Browse the repository at this point in the history
only restict to first if many observations per subjectId
  • Loading branch information
jreps authored Oct 31, 2023
2 parents e3a02bf + 81b9d02 commit 3dbcd90
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/PopulationSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ createStudyPopulation <- function(
if (firstExposureOnly) {
ParallelLogger::logTrace(paste("Restricting to first exposure"))

population <- population %>%
dplyr::arrange(.data$subjectId,.data$cohortStartDate) %>%
dplyr::group_by(.data$subjectId) %>%
dplyr::filter(dplyr::row_number(.data$subjectId)==1)
if (nrow(population) > dplyr::n_distinct(population$subjectId)) {
population <- population %>%
dplyr::arrange(.data$subjectId,.data$cohortStartDate) %>%
dplyr::group_by(.data$subjectId) %>%
dplyr::filter(dplyr::row_number(.data$subjectId)==1)
}

attrRow <- population %>% dplyr::group_by() %>%
dplyr::summarise(outcomeId = get('oId'),
Expand Down

0 comments on commit 3dbcd90

Please sign in to comment.