RStudio Binomial Test providing strange results I am running a series of binomial tests for different trials. I ran 319 trials, and no matter the number of successes, my p-value is still < 2.2e-16. This includes when my trial had 0 successes.
binom.test(0, 319, p=0.5, alternative = c ("two.sided"), conf.level = 0.95)

the results come out as...
Exact binomial test

data:  0 and 319
number of successes = 0, number of trials = 319, p-value < 2.2e-16
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
 0.00000000 0.01149728
sample estimates:
probability of success 
                     0 

A successful trial has the same p-value...
Exact binomial test

data:  21 and 319
number of successes = 21, number of trials = 319, p-value < 2.2e-16
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
 0.04120874 0.09887112
sample estimates:
probability of success 
            0.06583072 

Am I interpreting the results wrong? Please help!
 A: To help you understand the results, your binomial example is effectively testing if a coin is fair or not ($H_0: p = 0.5$) by flipping the coin 319 times.
The p-value represents the probability of obtaining results at least as extreme as what was observed if the null hypothesis was true.
Forgetting statistics and thinking logically, if you flipped a fair coin 319 times, how likely is it you would get 319 tails and 0 heads?  Virtually impossible, never going to happen.  In statistics that means the p-value is practically zero (or 2e-16 for a computer).
Again, if you flipped 319 times, how likely is it to get only 21 heads (or less)?  Still virtually impossible, never going to happen.  Again the p-value is still practically zero (or 2e-16).
If you change the number of successes to something more realistic (you would expect around half the flips to be heads with a fair coin), you will start getting results that support the null hypothesis being more reasonable (or more correctly, less evidence the null hypothesis is false).  Try the same test with 150 successes and you will get a different p-value.
A: The 319 trial binomial test is coming back close to zero as there's very little chance of getting that outcome. Probably what you really want is to test for that number of successes or more. Here's how to construct a table of probabilities for 100 tests, just change the 100 to 319 or whatever number is required. The table will include left tails, right tails, equal, and not equal, so just select as desired.
library(data.table)
DT=data.table(cbind(Heads=seq(100,0,by=-1), Tails=seq(0,100,by=1)))
DT[, BinomL := pbinom(Heads-1, Heads+Tails, 0.5), keyby=Heads]
DT[, BinomR := pbinom(Heads, Heads+Tails, 0.5, lower.tail=FALSE)]
DT[, BinomEQ := pbinom(Heads-1, Heads+Tails, 0.5, lower.tail=FALSE) - pbinom(Heads, Heads+Tails, 0.5, lower.tail=FALSE)]
DT[, BinomLR := BinomL + BinomR]
DT[, BinomTot := BinomL + BinomR + BinomEQ]
View(DT)

The C code underlying R binom/pbinom/etc. uses algorithm 708, so in theory you should have plenty of digits of precision.
