Hello, I am an epidemiologist and I am quite new to R. I have a simple vaccination data in long format which looks like:
data<-data.frame(id=c(1,1,1,1,2,2,2,3,3,3,3),date=c("01/12/2020","02/12/2020","03/12/2020","04/12/2020",
"01/31/2020","03/12/2020","04/05/2020","02/12/2020","04/12/2020","05/12/2020","01/12/2020"),vac_date=c("","02/02/2020","","04/02/2020","","","04/01/2020","","04/01/2020","05/01/2020",""),dose=c('',1,'',2,'','',1,'',1,2,''))
id = patient's identification
date = survey date
vac_date = vaccination date
dose = indicating the vaccination dose
I am really having trouble creating the frequency line plot in my mind. I tried
ggplot(data, aes(x = date, y = vac_date)) + geom_line()
The dates and counts of vaccination are confusing. I would like to compute 2 plots:
- frequency or proportion plot by date or week regardless of dose
- frequency or proportion plot by date or week by dose (overlay)
as shown in the following pic
Might someone please provide some help on getting the above plots? Thanks.