ddediu / AdhereR

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

FUW start does not recognise variable name for days since/before first event #141

Closed alexadima closed 3 years ago

alexadima commented 3 years ago

when calculating CMA with variable name for days since/before first event

cmasimplu <- CMA9(data=testdata1pat, ID.colname = "CHI", event.date.colname = "DisDate", event.duration.colname = "MinDuration", event.daily.dose.colname = "Min", medication.class.colname = "AdhereRLabel", carry.only.for.same.medication=FALSE, consider.dosage.change=FALSE, followup.window.start= "FUstartdays", followup.window.start.unit = "days", followup.window.duration = 365*2, followup.window.duration.unit = "days", observation.window.start= 0, observation.window.start.unit= "days", observation.window.duration=365, date.format="%Y-%m-%d");

I get warning messages:

Warning messages: 1: In .report.ewms("time.interval to '.add.time.interval.to.date' must be a positive integer.\n", : time.interval to '.add.time.interval.to.date' must be a positive integer.

2: In .report.ewms(paste0("The observation window is not within the follow-up window for participant(s) ", : The observation window is not within the follow-up window for participant(s) 18014359390 !

If I replace the variable name with the actual number of days, it calculates and plots OK.

test dataset in shared private folder

alexadima commented 3 years ago

if I make it "as.numeric" before calculating, it does recognise it. doh! maybe write 'your FUW start variable is not numeric, make it numeric and it will all be OK'. just in case there are other silly people like me?

ddediu commented 3 years ago

Fixed: now, timediffs are automatically converted to numbers as appropriate given the time units