merge_data.pdf (87.4 KB)
I want to assign the variable "1" in new column "drug_in_bcx_window" with a difference <=2, For >2 as "0".
#calculatation between last_administration_day and blood_culture_day.
drug <- ifelse(df$last_administration_day >= df$blood_culture_day & df$last_administration_day <= df$blood_culture_day, 1, 0)