ddediu / AdhereR

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

Plotting a simple CMAs with NAs for some patients seems to crash #144

Closed ddediu closed 3 years ago

ddediu commented 3 years ago

E.g.:

d <- med.events[med.events$PATIENT_ID %in% 1:5,];
cma1 <- CMA1(data=d,
             ID.colname="PATIENT_ID",
             event.date.colname="DATE",
             event.duration.colname="DURATION",
             event.daily.dose.colname="PERDAY",
             medication.class.colname="CATEGORY",
             followup.window.start="10/26/2031", #min date
             observation.window.start=0,
             observation.window.duration=365,
             date.format="%m/%d/%Y");
plot(cma1);

produces:

Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 5, 3 
ddediu commented 3 years ago

For patients with no events in the FUW draw a warning saying so...

ddediu commented 3 years ago

Fixed! In fact, it was worse, in that patients without CMA estimates (all events outside FUW/OW) were causing the crash. Now, fixed to don't display them (with a warning that some were removed) or don't plot at all if all are like this...