Skip to content

Commit

Permalink
Preventing duplicate calendar time and age knots, causing unique key …
Browse files Browse the repository at this point in the history
…violation errors when uploading.
  • Loading branch information
Admin_mschuemi authored and Admin_mschuemi committed May 23, 2024
1 parent 89755c2 commit 8ad50eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Bugfixes

2. Fixed case count in `createStudyPopulation()` when restricting time in prior `getDbSccsData()` call, e.g. by defining a study period and/or nesting cohort.

3. Preventing duplicate calendar time and age knots, causing unique key violation errors when uploading.


SelfControlledCaseSeries 5.1.1
==============================
Expand Down
2 changes: 2 additions & 0 deletions R/SccsDataConversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ addAgeSettings <- function(settings,
transmute(outcomeAge = .data$outcomeDay + .data$ageAtObsStart) %>%
pull() %>%
quantile(seq(0.01, 0.99, length.out = ageCovariateSettings$ageKnots))
ageKnots <- ageKnots[!duplicated(ageKnots)]
} else {
ageKnots <- ageCovariateSettings$ageKnots
}
Expand Down Expand Up @@ -328,6 +329,7 @@ addCalendarTimeSettings <- function(settings,
for (j in seq_len(knotsInPeriod)) {
calendarTimeKnots[j] <- min(countsInPeriod$month[countsInPeriod$cumCount >= cutoffs[j]])
}
calendarTimeKnots <- calendarTimeKnots[!duplicated(calendarTimeKnots)]
calendarTimeKnotsInPeriods[[length(calendarTimeKnotsInPeriods) + 1]] <- calendarTimeKnots
}
} else {
Expand Down

0 comments on commit 8ad50eb

Please sign in to comment.