ddediu / AdhereR

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

cma per episode and cma sliding window require as.data.frame to be able to plot #19

Closed alexadima closed 5 years ago

alexadima commented 5 years ago

otherwise: Error in plot.window(...) : need finite 'xlim' values

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),] cmaE <- CMA_per_episode(CMA="CMA7", # apply the simple CMA7 to each treatment episode med_events_A09, ID.colname="ID", event.date.colname="DATE.DISP", event.duration.colname="DURATION", event.daily.dose.colname="DAILY.DOSE", medication.class.colname="ATC.CODE", carryover.within.obs.window = TRUE, carry.only.for.same.medication = FALSE, consider.dosage.change = FALSE, # conditions on treatment episodes medication.change.means.new.treatment.episode = TRUE, maximum.permissible.gap = 90, maximum.permissible.gap.unit = "days", followup.window.start=0, followup.window.start.unit = "days", followup.window.duration = 3653, followup.window.duration.unit = "days", observation.window.start=0, observation.window.start.unit = "days", observation.window.duration=3653, observation.window.duration.unit = "days");

plot(cmaE, patients.to.plot=c("8"), show.legend=FALSE);

ddediu commented 5 years ago

Fixed by forcing conversion to data.frame