R Binomial Test


binom.test() function performs binomial test of null hypothesis about binomial distribution.

binom.test(x,n,p=0.5,alternative=c("two.sided","less","greater"),
    conf.level=0.95)

x: number of successes
n: number of trials
p: hypothesized probability of success
alternative: alternative hypothesis, including "two.sided","greater","less"
conf.level: confidence level

Suppose in a coin tossing, the chance to get a head or tail is 50%. In a real case, we have 100 coin tossings, and get 48 heads, is our original hypothesis true?
> binom.test(48,100)
        Exact binomial test

data:  48 and 100
number of successes = 48, number of trials = 100, p-value = 0.7644
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
 0.3790055 0.5822102
sample estimates:
probability of success 
                  0.48 

Since the p-value is 0.7644, far greater than 0.05, the hypothesis is accepted.