Bug 14329 - wilcox.test exits ungracefully for a constant vector
Summary: wilcox.test exits ungracefully for a constant vector
Alias: None
Product: R
Classification: Unclassified
Component: Analyses (show other bugs)
Version: old
Hardware: ix86 (32-bit) Mac OS X v10.5
: P5 normal
Assignee: R-core
Depends on:
Reported: 2010-07-08 03:13 UTC by elipapa
Modified: 2018-04-09 15:31 UTC (History)
1 user (show)

See Also:


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 


gives the inconsistent

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

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