[R] How to count from larger value to smaller value in ecdf (Empirical Cumulative Distribution Function)

Henrique Dallazuanna wwwhsd at gmail.com
Tue Feb 19 17:21:49 CET 2008


Maybe one option should be:

ecdf2 <- function (x)
{
    x <- sort(x, decreasing = TRUE)  # Changed Line
    n <- length(x)
    if (n < 1)
        stop("'x' must have 1 or more non-missing values")
    vals <- 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
}

See the source code of ecdf



On 19/02/2008, Hyunchul Kim <sundol313 at naver.com> wrote:
> Hi, all
>
> ecdf function (Empirical Cumulative Distribution Function) in "stats"
> package  counts from smaller values to larger values.
> However, I want to draw it by counting from larger value to smaller values
> and I couldn't find options for this purpose.
>
> How can I draw ecdf or ecdf like graph by counting from larger values to
> smaller values.
>
> Thank you in advance.
>
> Hyunchul Kim
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list