I am using a for loop obtain a set of p-values using the "pbinom" function. The values 1:5 simply refer to the number of observed counts, 21, refers to the sample size, and 0.05 refers to the probability of success:
for ( i in 1:5) {
print (1 - pbinom(i, 21, 0.05))
}
[1] 0.2830282
[1] 0.08491751
[1] 0.01888063
[1] 0.00324032
[1] 0.0004415266
This code works fine, but it just outputs the values the values on the command prompt as above.
My question is, how can I store the output in a variable?
I tried
output<-for ( i in 1:5) {
print (1 - pbinom(i, 21, 0.05))
}
But when I entered "output", I received "NULL" in response.
Any help would be appreciated, Thanks.