ddediu / AdhereR

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

Overlapping CMA % on CMA7 [bug] #131

Closed dffyfe closed 4 years ago

dffyfe commented 4 years ago

When plotting CMA7 and where there are patients with only 1 or 2 events, the green outline of the CMA often overlap.

df3 <- med.events
colnames(df3) <- c("AdhereRLabel", "DisDate", "Min", "Category", "MinDuration")
str(df3)
df3$DisDate <- parse_date_time(df3$DisDate, "%m-%d-%Y")
CHIs <- unique(df3$AdhereRLabel)

cma7 <- CMA7(data=df3[df3$AdhereRLabel %in% CHIs[2:10] & df3$Category=="medB",],
              ID.colname = "AdhereRLabel",
              event.date.colname = "DisDate",
              event.duration.colname = "MinDuration",
              #event.daily.dose.colname = "Min",
              #medication.class.colname = "Category",
              carry.only.for.same.medication = FALSE,
              medication.change.means.new.treatment.episode = TRUE,
              #maximum.permissible.gap = 1000,
              #maximum.permissible.gap.unit = "days",
              followup.window.start = 0,
              #followup.window.start.unit = "days",
              followup.window.duration = 365*2,
              followup.window.duration.unit = "days",
              observation.window.start = 28*6,
              observation.window.start.unit = "days",
              observation.window.duration = 365,
              observation.window.duration.unit = "days",
              date.format = "%m-%d-%Y")

plot(cma7, show.period = "dates", 
     period.in.days = 84,
     show.legend = FALSE,
     ylab = c(withCMA = "Drug Unique Code"),
     title = "Patients 2:10",
     plot.CMA = T,
     plot.CMA.as.histogram = F,
     min.plot.size.in.characters.horiz=0,
     min.plot.size.in.characters.vert=0) 
ddediu commented 4 years ago

Hi David, I can't reproduce it as I don't know what df3 is :( Could you pls also tell me how to create this dataset or, if not possible, provide it for me as a CSV file (google drive/dropbox/email)? Thanks, Dan

dffyfe commented 4 years ago

Hi Dan,

Sorry about this, df3 is med.events, the triple ` cut off the first line.

Best,

ddediu commented 4 years ago

Cool, the example is reproducible: thanks!

ddediu commented 4 years ago

Fixed by making the summary plot smaller for 1 or 2 events (however, might need to shrink the font manually if the vertical plotting space is too small)