#Comparing oscillatory ventilation vs routine ventilation

#Two groups (A and B) and a categorical variable (Outcome: Success/Failure)
group_osc_success <- 27
group_osc_failure <- 143
group_rou_success <- 48
group_rou_failure <- 124

#Create a matrix for the contingency table

data_matrix <- matrix(c(group_osc_success, group_osc_failure,
                        group_rou_success, group_rou_failure),
                      nrow = 2, byrow = TRUE,
                      dimnames = list(Group = c("Group osc", "Group rou"),
                                      Outcome = c("Success", "Failure")))
print(data_matrix)
##            Outcome
## Group       Success Failure
##   Group osc      27     143
##   Group rou      48     124

#chi square test

chi_square_result <- chisq.test(data_matrix)
print(chi_square_result)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  data_matrix
## X-squared = 6.5353, df = 1, p-value = 0.01058