savicky at cs.cas.cz
2006-Oct-11 05:28 UTC
[Rd] expression as a parameter of binom.test (PR#9288)
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 while> binom.test(5600,10000)yields correct result. The same error occurrs for> binom.test(0.57*10000,10000)
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 integerWell, 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
ripley at stats.ox.ac.uk
2006-Oct-11 08:09 UTC
[Rd] expression as a parameter of binom.test (PR#9288)
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