Bugzilla – Bug 14329
wilcox.test exits ungracefully for a constant vector
Last modified: 2010-07-12 19:53:48 UTC
whenever wilcox.test is given a constant vector, it exits with an error:
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.
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:
difference in location
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. |
changed in 2.12.0