R reference

Hypothesis testing functions

Function Test Usage Notes
binom.test() Run an exact binomial test binom.test(k, n, null_p Remember to specify the null probability of success as the final argument
chisq.test() Run a goodness of fit test chisq.test(<observed counts>, p = <null frequencies>) chisq.test(c(100, 150, 32), p = c(1/3, 1/3, 1/3))
chisq.test() Run a contingency table analysis chisq.test(<contingency table>) cont.table <- rbind(c(45,54), c(67,88))

fisher.test() Run Fisher’s exact test fisher.test(<contingency table>) Usage is the same as for contingency chisq.test()

2x2 contingency table calculations


  • Odds ratio = (or reciprocal)

  • Relative risk for Row1 over Row2 =