[Rd] approxfun(*, ties=) returning "random" result (PR#986)

Thomas Lumley tlumley@u.washington.edu
Mon, 18 Jun 2001 11:45:52 -0700 (PDT)

On Mon, 18 Jun 2001 maechler@stat.math.ethz.ch wrote:

>   Platforms  : SunOS and Linux, both using gcc 2.95.[23]
>   R versions : 1.2.3 and "R-devel"
> I came accross this when trying to debug a somewhat sub-optimal behavior of
> ecdf() from package stepfun.
> What happens is that  approxfun(*, ties = <function>)
> does not always return the same result for identical arguments.
> I tried "min", "max", and "mean" all of which are mentioned on the help page.
> From looking at both R and C code, I wonder if the bug is not even deep
> inside where .C(......) is handled, or somewhere else ``deep down''...

No, the problem is that `n', the length of the x and y vectors, is not
recomputed when the ties are removed.  Thus in your example two 9-element
vectors are passed down to a C routine that is told they are 16 elements
long. Bad.

I'll commit the obvious fix after make check.


r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch