I'm trying to think about how one drug is prescribed in the hospital. In this dummy database, I have 1000 contacts with the patient after 2017/01/01.
The purpose of the construction is to see the pattern of administration of this drug: is it given more often / with a high dose closer to the time of administration, discharge, or in the middle of the patientβs stay.
#Get_random_dates that we will use multiple times gen_random_dates <- function(N, st, et) { st <- as.POSIXct(as.Date(st)) et <- as.POSIXct(as.Date(et)) dt <- as.numeric(difftime(et,st,unit="sec")) ev <- runif(N, 0, dt) rt <- st + ev return(rt) }
I tried this ggplot function but it did not help me render the template.
ggplot(patient_data, aes(x = admin_date, y = admin_dose)) + xlab("Use of Drug in Patient Encounters") + ylab("Dose (mg)") + geom_jitter()
ggplot

source share