From Roger.Bivand at nhh.no  Wed Oct 11 09:17:03 2006
From: Roger.Bivand at nhh.no (Roger Bivand)
Date: Wed, 11 Oct 2006 09:17:03 +0200 (CEST)
Subject: [Rd] expression as a parameter of binom.test (PR#9288)
In-Reply-To: <20061011052809.9D29828FA9@slim.kubism.ku.dk>
Message-ID: <Pine.LNX.4.44.0610110904170.21219-100000@reclus.nhh.no>

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.

> 
> 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
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




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