You can also use prop.test
from package stats
, or binom.test
prop.test(x, n, conf.level=0.95, correct = FALSE)
1-sample proportions test without continuity correction
data: x out of n, null probability 0.5
X-squared = 1.6, df = 1, p-value = 0.2059
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.4890177 0.5508292
sample estimates:
p
0.52
You may find interesting the article TWO-SIDED CONFIDENCE INTERVALS FOR THE SINGLE PROPORTION: COMPARISON OF SEVEN METHODS, where in Table 1 on page 861 are given different confidence intervals, for a single proportion, calculated using seven methods (for selected combinations of n and r). Using prop.test
you can get the results found in rows 3 and 4 of the table, while binom.test
returns what you see in row 5.