Bug 14329 - wilcox.test exits ungracefully for a constant vector
wilcox.test exits ungracefully for a constant vector
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Analyses
R 2.11.1 patched
ix86 (32-bit) Mac OS X v10.5
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-08 03:13 UTC by elipapa
Modified: 2010-07-12 19:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description elipapa 2010-07-08 03:13:30 UTC
whenever wilcox.test is given a constant vector, it exits with an error:

> wilcox.test(c(1,1,1,1,1),c(1,1,1,1,1,1),conf.int=T)
Error in if (f.lower <= 0) return(mumin) : 
  missing value where TRUE/FALSE needed


this can be particularly disruptive (and obscure) if you are using wilcox.test as part of an apply.
Comment 1 Peter Dalgaard 2010-07-08 08:36:19 UTC
To be precise, this only occurs when conf.int=TRUE.

The proximate cause is that SIGMA.CI becomes zero so there's a divide by zero condition.

Note, by the way, that the corner case 

wilcox.test(1,2,conf.int=TRUE)

gives the inconsistent

-------
0 percent confidence interval:
 -1 -1 
sample estimates:
difference in location 
                    -1 

Warning message:
In wilcox.test.default(1, 2, conf.i = T) :
  Requested conf.level not achievable
---------

(this could well be a platform-dependent rounding issue)

An easy fix would seem to be to make the internal root() function return NaN if it encounters is.na(f.lower), but perhaps an explicit test would be better. |
Comment 2 Brian Ripley 2010-07-12 19:53:48 UTC
changed in 2.12.0