Skip to content
Prev 67606 / 398506 Next

i param in "for" loop does not takes zeros?

The for loop is not ignoring the zero at all, but the assignment is,
since R indexes starting at 1, not zero.
numeric(0)

To run this loop this way, you need to add one to the index:
for ( i in 0:5 )
  sim[i+1] <- dbinom(i, 5, p)

However, you'd be better off passing your vector of values directly to
dbinom():
[1] 0.32768 0.40960 0.20480 0.05120 0.00640 0.00032
[1] TRUE

Cheers,
Rich
On 4/14/05, Francisco J. Zagmutt <gerifalte28 at hotmail.com> wrote: