OHDSI / Achilles

Automated Characterization of Health Information at Large-scale Longitudinal Evidence Systems (ACHILLES) - descriptive statistics about a OMOP CDM database
https://ohdsi.github.io/Achilles/
130 stars 122 forks source link

performTemporalCharacterization fails with error in window.default(x, ...) : 'start' cannot be after 'end' #734

Open xitology opened 1 year ago

xitology commented 1 year ago

On our OMOP dataset, Achilles::performTemporalCharacterization() fails with the output:

Error in window.default(x, ...) : 'start' cannot be after 'end'
Calls: <Anonymous> ... <Anonymous> -> window -> window.ts -> as.ts -> window.default
Execution halted

This error could be traced to an invocation of Achilles::tsCompleteYears(). This function is called on a time series to exclude partial years from the beginning and the end of the series. However, Achilles::tsCompleteYears() fails when the time series does not contain a full year interval. The problem could be easily reproduced with:

$ Rscript -e 'Achilles::tsCompleteYears(ts(1:20, frequency = 12, start = c(2022, 02)))'
Error in window.default(x, ...) : 'start' cannot be after 'end'
Calls: <Anonymous> -> window -> window.ts -> as.ts -> window.default
Execution halted