[Rd] Sort in ecdf

From: Shiazy Fuzzy <shiazy_at_gmail.com>
Date: Wed, 30 May 2007 20:07:24 +0200


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,


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 30 May 2007 - 18:10:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 May 2007 - 20:35:58 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.