ddediu / AdhereR

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

Make CMA computation, printing and plotting %>%-friendly #180

Closed ddediu closed 2 years ago

ddediu commented 2 years ago

might make it easier to use in a tidy-verse-like dialect...

ddediu commented 2 years ago

It actually is pipe-friendly! E.g.:

library(AdhereR);
library(dplyr);
x <- med.events %>%
  filter(PATIENT_ID %in% c(1,2,3)) %>%
  CMA0(ID.colname="PATIENT_ID",
       event.date.colname="DATE",
       event.duration.colname="DURATION",
       event.daily.dose.colname="PERDAY",
       medication.class.colname="CATEGORY",
       followup.window.start=230,
       followup.window.duration=705,
       observation.window.start=41,
       observation.window.duration=100,
       date.format="%m/%d/%Y") %>%
  plot()