Description Usage Arguments Value Functions Examples
Create tibble with weighted ECDF
1 | mutate_ewcdf(data, variable, weights)
|
data |
input dataset |
variable |
input variable |
weights |
input weights |
tibble
mutate_ewcdf
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # source("https://raw.githubusercontent.com/NicolasWoloszko/stat_ecdf_weighted/master/stat_ecdf_weighted.R")
# https://stat.ethz.ch/pipermail/r-help/2012-October/337288.html
# https://stackoverflow.com/questions/32487457/r-ggplot-weighted-cdf
library(tidyverse)
x <- rnorm(100)
w <- runif(100)
a <- ecdf(x = x)
b <- spatstat.geom::ewcdf(x = x,weights = w)
#plot(a)
#plot(b)
tibble(x=x,w=w) %>%
mutate_ewcdf(variable = x,weights = w) %>%
ggplot() +
geom_step(aes(x = x,y = ecdf_x),color="black") +
geom_step(aes(x = x,y = ewcdf_x),color="red")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.