I have the following data frame:
df <-read.table(header=TRUE, text="id time Medication
1 90 1 AA
2 87 0 BB
3 50 1 DD
4 54 0 OX
5 30 0 AR
6 15 1 FM
7 20 1 FM
8 20 0 BB
9 12 0 AA
10 13 1 AA")
and a list that contains medications of interest:
medications <- c('AA', 'BB', 'FM')
I want to subset the data according to the medications available in medications
. So far I have tried the following:
Medications_reduced <- df %>%
subset(df$Medication %in% medications)