Hi there! I am new to R and could really use help! I have this table below I created with a pivot function that is organized by unique patients then the columns are unique respiratory/cardio procedures each patient could have had. 1 = yes to that procedure. I want to group patients by if they have/have not received certain procedures (1. Non-invasive NI procedure, 2. Invasive intubation procedures, and 3. Neither NI or Intubations). I could use help with my code--it is not working for some reason! I have the table and my code below.
#READING DATA
Proc <- read.csv("Procedure.csv", stringsAsFactors = F)#CLEANING DATA
AllProc <- select(Proc, Case.Index.Id, Procedure.Name)
AllProcTidy <- pivot_wider(AllProc,
names_from = Procedure.Name,
values_from = Procedure.Name,
values_fill = 0,
values_fn = function(x) 1)NI_RespPro <- c("BiPAP", "BiPAP (non-invasive)", "CPAP", "CPAP (Non-Invasive")
NI_tx <- filter(AllProcTidy, %in% NI_RespPro, group_by = Case.Index.Id)Invasive_RespPro <- c("Endotracheal Intubation(and duration of intubation)")
Invasive_tx <- filter(AllProcTidy, %in% Invasive_RespPro)No_tx <- filter(AllProcTidy, !Procedure.Name %in% c(NI_RespPro, Invasive_RespPro))