I'm currently working with a data frame where I wish to summarize drug dosage per day per patient. With the tidyverse I tried using a
df%>%
group_by (patient, date)%>%
summarise(doseperday = aggregate(drugdose)
but no luck.
I.e.
|patient|drugdose|date |
|Bob |5 |10/10/18|
|Bob |3 |10/10/18|
|Bob |4 |10/11/18|
|Bob |1 |10/11/18|
|Jim |5 |10/10/18|
|Jim |8 |10/10/18|
|Jim |3 |10/11/18|
|Jim |1 |10/11/18|
I want to get the following:
|patient|drugdose|date |
|Bob |8 |10/10/18|
|Bob |5 |10/11/18|
|Jim |12 |10/10/18|
|Jim |4 |10/11/18|
Thanks for the help.