I have a table "AllProc" that have a unique identifier for every patient (Case.Index.Id) and a variety of resp support each patient received during their admission (BiPAP, etc), 1 = received, 0 = did not receive.
I want to add two new columns to this data table, creating a master table "AllProcMaster". One column "NI_TX" for patients who only received "Non-Invasive" resp support (BiPAP, CPAP), and another column "NO_TX" for patients who received neither non-invasive or invasive support (Intubation). In my actual dataset, I have many more resp procedures, which is why I can't just isolate only "O2" for patients in this "NO_TX" column. This is the code I made, which did not work!
NI_RespPro <- c("BiPAP", "BiPAP", "CPAP")
Invasive_RespPro <- c("Intubation")
NIandIN_RespPro<- c("BiPAP", "CPAP", "Intubation")
AllProcMaster <- AllProc %>%
mutate(NI_TX = ifelse(all_of(NI_RespPro), 1, 0, group_by(Case.Index.Id))) %>%
mutate(No_TX = ifelse(all_of(NIandIN_RespPro) = 0, 1, group_by(CAse.Index.Id)))