[R] Bug in ecdf? Or what am I missing?
Ben Bolker
bolker at ufl.edu
Sun Feb 28 17:21:52 CET 2010
Ajay Shah <ajayshah <at> mayin.org> writes:
>
> x <- c(6.6493705109108, 7.1348436721241, 8.76886994525624,
> 6.12907548096037, 6.88379118678109, 7.17841879427688,
> 7.90737237492867, 7.1207373264833, 7.82949407630692,
> 6.90411547316105)
> plot(ecdf(x), log="x")
>
> It does the plot fine, but complains:
>
> Warning message:
> In xy.coords(x, y, xlabel, ylabel, log) :
> 1 x value <= 0 omitted from logarithmic plot
>
I can at least explain why this happens.
plot() calls plot.ecdf() which calls plot.stepfun() which
calls
plot(0, 0, type = "n", xlim = xlim, ylim = ylim, xlab = xlab,
ylab = ylab, main = main, ...)
to set up the plot axes.
Arguably this could be fixed within R *either* by changing the line
above to
plot(1, 1, type = "n", xlim = xlim, ylim = ylim, xlab = xlab,
ylab = ylab, main = main, ...)
[I can't see how this would break anything??]
*or* by going to the location of the warning and suppressing
it when type="n" -- the latter is a more general solution,
but harder, because the checks appear to be in
various functions (xy.coords and xyz.coords) that don't know
(internally) whether type="n" or not ...
I don't know whether I would formally count this as a bug
or not (a minor one, at most), but it would probably worth
following up on R-devel if you feel strongly about it.
Ben Bolker
More information about the R-help
mailing list