I would like to perform the exact binomial test, with binom
R package(binom.test
function), to 4 different number of successes with 4 different probability values.
I can do it singularly, but I would like to know if I can write a code to do the calculation in only one command (e.g. lapply, for loop).
x <- c(68, 69, 70, 75) #number of successes
p <- c(1/365, 2/365, 3/365, 4/365) #probability of success
n <- 265 #number of trials
The conf.level = 0.95
and alternative = "two.sided"
(as the outcome can be as 1 or 0).
Any suggestion?
I tried:
for (i in 1:4) {
test[i] <- binom.test(x[i], n, p[i], alternative = "two.sided", conf.level = 0.95)
}
but doesn't work.