[R] About 'choose' function

John cyracules at yahoo.co.uk
Mon Nov 8 12:58:04 CET 2004


Hello R-users,

When I didn't know about the internal 'choose'
function, I made such function, 'my.choose' below. But
when I used them instead of choose(6000,20), they
didn't give me any answer.

What is the difference between 'choose', 'my.choose1',
and 'my.choose2' below? That is, what is behind
'choose' function and what's the problem using 'prod'
or 'gamma' function?

Thanks a lot.

John

##########

> choose(6000,20)
[1] 1.455904e+57
>
> my.choose1 <- function(x,y) {
prod(1:x)/(prod(1:y)*prod(1:(x-y))) }
> my.choose1(6000,20)
[1] NaN
>
> my.choose2 <- function(x,y) {
gamma(x+1)/(gamma(y+1)*gamma(x-y+1)) }
> my.choose2(6000,20)
[1] NaN
>




More information about the R-help mailing list