From shiazy at gmail.com  Wed May 30 20:07:24 2007
From: shiazy at gmail.com (Shiazy Fuzzy)
Date: Wed, 30 May 2007 20:07:24 +0200
Subject: [Rd] Sort in ecdf
Message-ID: <9d3ef91d0705301107h39f396c8wbfe16df9903d441e@mail.gmail.com>

Hi!

I've noticed the ecdf() R code (R ver. 2.5.0) contains two call to sort:
--- [R-code] ---
ecdf <- function(x)
        x <- sort(x)
        n <- length(x)
        if (n < 1)
                stop("'x' must have 1 or more non-missing values")
        vals <- sort(unique(x))
        rval <- approxfun(vals, cumsum(tabulate(match(x, vals)))/n,
        method = "constant", yleft = 0, yright = 1, f = 0, ties = "ordered")
        class(rval) <- c("ecdf", "stepfun", class(rval))
        attr(rval, "call") <- sys.call()
        rval
--- [/R-code] ---

I think one of the two calls to sort can be removed, improving the performance.

What do you think?

Sincerely,

-- Marco



[Rd] Sort in ecdf
Shiazy Fuzzy