[Rd] expression as a parameter of binom.test (PR#9288)

ripley at stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Oct 11 10:09:41 CEST 2006


On Wed, 11 Oct 2006, Roger Bivand wrote:

> On Wed, 11 Oct 2006 savicky at cs.cas.cz wrote:
>
>> Full_Name: Petr Savicky
>> Version: 2.4.0
>> OS: Fedora Core release 2
>> Submission from: (NULL) (62.24.91.47)
>>
>>
>> the error is
>>
>>> binom.test(0.56*10000,10000)
>> Error in binom.test(0.56 * 10000, 10000) :
>>         'x' must be nonnegative and integer
>
> Well, do:
>
> binom.test(as.integer(0.56*10000),10000)
>
> then.
>
> storage.mode(0.56*10000)
>
> is "double", not "integer". Footnote 9 in "An Introduction to R", and in
> the table early in Chapter 2 in "R Language Definition". In fact it is
> another rendition of FAQ 7.31 (is anybody logging a time series of 7.31?):
>
> x <- 0.56*10000
> x1 <- 5600
> all.equal(x, x1)
> identical(x, x1)
>
> and fails:
>
> x != round(x)
>
> in binom.test; it passes:
>
> !isTRUE(all.equal(x, round(x)))
>
> which might be more graceful.

I think we would want an absolute and not relative tolerance there.
I've allowed a 1e-7 fuzz in R-devel.

>
>>
>> while
>>
>>> binom.test(5600,10000)
>>
>> yields correct result.
>>
>> The same error occurrs for
>>> binom.test(0.57*10000,10000)
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-devel mailing list