Proportion test in R

How to do a proportion test in R and what are the conditions need to met for proportion test?

  1. The sampling method for each population is simple random sampling.
  2. The samples are independent.
  3. Each sample includes at least 10 successes and 10 failures.
  4. Each population is at least 20 times as big as its sample.

The proportions test is used to compare two observed proportions or single sample observations. This article describes the basics of proportions analysis in R.


In statistics, we can define the corresponding null hypothesis (H0) as follow:

  1. H0:pA=pB
  2. H0:pA≤pB
  3. H0:pA≥pB

The corresponding alternative hypotheses (Ha) are as follow:

  1. Ha:pA≠pB  (different)
  2. Ha:pA>pB  (greater)
  3. Ha:pA<pB (lesser)

1 is two-tailed tests and 2 & 3 are one tailed test.

R functions prop.test() can be used for calculating proportion significance.

The One-Sample Proportion Test is used to assess whether a population proportion (P1) is significantly different

from a hypothesized value (P0). This is called the hypothesis of inequality. The hypotheses may be stated in terms

of the proportions, their difference, their ratio, or their odds ratio, but all four hypotheses result in the same test statistics. 

prop.test(x,n,p=NULL, alternative = “two.sided”, correct = TRUE)

two-sided test

prop.test(x = c(490, 400), n = c(500, 500))

one sided test

prop.test(x = c(400, 350), n = c(500, 500), alternative = “less”)


prop.test(x = c(400, 350), n = c(500, 500), alternative = “greater”)


The p-value of the test which is less than the significance level alpha = 0.05. We can conclude that the proportion of samples is significantly different in the two groups with a p-value = 0.0001728.

One Sample Analysis in R

You may also like...

1 Response

Leave a Reply

Your email address will not be published.

ten + 6 =


Subscribe Now