ddediu / AdhereR

Computation of adherence to medications from Electronic Healthcare Data in R
26 stars 6 forks source link

error display per episode and sliding windows plotting new dataset #16

Closed alexadima closed 5 years ago

alexadima commented 5 years ago

event_durations <- compute_event_durations(disp.data = durcomp.dispensing, presc.data = durcomp.prescribing, hosp.data = durcomp.hospitalisation, ID.colname = "ID", presc.date.colname = "DATE.PRESC", disp.date.colname = "DATE.DISP", date.format = "%d.%m.%Y", medication.class.colnames = c("ATC.CODE", "UNIT", "FORM"), total.dose.colname = "TOTAL.DOSE", presc.daily.dose.colname = "DAILY.DOSE", presc.duration.colname = "PRESC.DURATION", visit.colname = "VISIT", force.init.presc = FALSE, force.presc.renew = TRUE, split.on.dosage.change = TRUE, trt.interruption = "continue", suppress.warnings = FALSE, return.data.table = TRUE) event_durations <- event_durations[!is.na(event_durations$DURATION),] med_events_A09 <- event_durations[grepl("^A09A",ATC.CODE),] plot_interactive_cma(data=med_events_A09, cma.class="per episode", ID.colname="ID", event.date.colname="DATE.DISP", event.duration.colname="DURATION", event.daily.dose.colname="DAILY.DOSE", medication.class.colname="ATC.CODE");

gives error: Plotting patient ID '1' with CMA 'per episode' ('CMA1') Error in plot.window(...) : need finite 'xlim' values

with the original dataset it works just fine

plot_interactive_cma(data=med.events, cma.class="per episode", ID.colname="PATIENT_ID", event.date.colname="DATE", event.duration.colname="DURATION", event.daily.dose.colname="PERDAY", medication.class.colname="CATEGORY");

only difference I see is that the format for the date variable in the new dataset is date, not string. but changing it to string does not solve it...

ddediu commented 5 years ago

Was a problem when passing a data.table as the data argument: now, in such a case, I force a conversion back to data.frame...