R/stat_cedf.R

# # Wciagnać kiedy wejdzie nowa wersja ggplot2
# 
# geom_cedf <- function(mapping = NULL, data = NULL, geom = "point",
#                       position = "identity", show.legend = NA,
#                       inherit.aes = TRUE, ...) {
#   layer(
#     stat = StatCedf,
#     data = data,
#     mapping = mapping,
#     geom = geom,
#     position = position,
#     show.legend = show.legend,
#     inherit.aes = inherit.aes,
#     params = list(...)
#   )
# }
# 
# 
# StatCedf <- ggproto(
#   "GeomCedf", Stat,
#   compute_group = function(data, scales) {
#     x <- sort(data$x)
#     n <- length(x)
#     if (n < 1)
#       stop("'x' must have 1 or more non-missing values")
#     vals <- unique(x)
#     rval <-
#       approxfun(
#         vals, 1 - cumsum(tabulate(match(x, vals))) / n,
#         method = "constant", yleft = 0, yright = 1, f = 0, ties = "ordered"
#       )
#     class(rval) <-
#       c("ecdf", "stepfun", class(rval))
#     assign("nobs", n, envir = environment(rval))
#     attr(rval, "call") <- sys.call()
#     data.frame(x = sort(x),y = rval(sort(x)))
#   },
# 
#   required_aes = c("x")
# )
Nicolabo/PERUanalytics documentation built on May 7, 2019, 6:18 p.m.