make_2x2 <- function(exp_yes, exp_no, notexp_yes, notexp_no, exposure) {
as.table(matrix(c(exp_yes, exp_no, notexp_yes, notexp_no), nrow = 2, byrow = TRUE, dimnames = list(c(exposure, paste("No",exposure)), c("Yes","No"))))
}
chisq.test(make_2x2(10,990,100,9900,"Risk"))
Created
July 30, 2019 19:15
-
-
Save narath/8b32310d32f3c77620c4f6ec387f2ac9 to your computer and use it in GitHub Desktop.
R: Create 2x2 table manually
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment