[Rd] 'ecdf': how about exploiting property that 'x' is sorted?

Suharto Anggono Suharto Anggono suharto_anggono at yahoo.com
Tue Feb 5 12:09:45 CET 2013


In the code of function 'ecdf' di R (for example, version 2.15.2), input 'x' is sorted first. Because the values are sorted, same values are contiguous. So, how about using an approach as inside function 'rle'? Because missing values is removed by 'sort', it can be done like this.

i <- c(which(x[-1L] != x[-n]), n)
rval <- approxfun(x[i], i/n, ...)



More information about the R-devel mailing list