I have these two tables I subsetted from a larger table:
table1 <- parent_table[parent_table$diag %in% c('a', 'b', 'c'), parent_table$patient_id]
table2 <- parent_table[parent_table$med %in% c('d', 'e', 'f'), parent_table$patient_id]
I then merge these two tables, on patient_id
to see which patients received a medication for the diagnosis.
merge1 <- merge(table1, table2, by="patient_id", all = TRUE)
I would now like do analysis on those who did NOT receive an antibiotic, i.e. those who are included in table1
, but not merge1
.