**Fisher’s Exact Test** is a test of significance that is used in place of a Chi Square Test in 2×2 tables when the sample sizes are small.

This tutorial explains how to conduct Fisher’s Exact Test in R.

**Fisher’s Exact Test in R**

In order to conduct Fisher’s Exact Test in R, you simply need a 2×2 dataset. Using the code below, I generate a fake 2×2 dataset to use as an example:

#create 2x2 dataset data = matrix(c(2,5,9,4), nrow = 2) #view dataset data # 2 9 # 5 4

To conduct Fisher’s Exact Test, we simply use the following code:

fisher.test(data)

This produces the following output:

In Fisher’s Exact Test, the null hypothesis is that the two columns are independent (or equivalently, that the odds ratio is equal to 1). To determine if the two columns are independent, we can look at the p-value of the test. In this case the p-value is 0.1597, which tells us we do not have sufficient evidence to reject the null hypothesis. Thus, we cannot say that there is any statistically significant difference between the two columns.

Note that the odds ratio is 0.1957871. Since the p-value of the test is 0.1597, this tells us that the odds ratio is not significantly different than 1.

The output of the test also gives us a 95% confidence interval for the odds ratio, which is:

(0.0130943, 1.8397543)

Since the number “1” is within this ratio, it confirms that the odds ratio is not significantly different than 1 (assuming we use alpha level 0.05).