Hyunchul Kim
2008-Feb-19 16:06 UTC
[R] How to count from larger value to smaller value in ecdf (Empirical Cumulative Distribution Function)
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]]
Henrique Dallazuanna
2008-Feb-19 16:21 UTC
[R] How to count from larger value to smaller value in ecdf (Empirical Cumulative Distribution Function)
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