mutate_ewcdf: Weighted ECDF

Description Usage Arguments Value Functions Examples

View source: R/cdc_weight.R

Description

Create tibble with weighted ECDF

Usage

1

Arguments

data

input dataset

variable

input variable

weights

input weights

Value

tibble

Functions

Examples

 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")

avallecam/cdcper documentation built on Dec. 19, 2021, 5:46 a.m.