dplyR has as cume_dist function

tidyverse
dplyr
Author

ChuckPR

Published

October 17, 2024

Useful for making ECDF charts in combination with geom_step.

suppressPackageStartupMessages(
  library('tidyverse')
)
library('palmerpenguins')

penguins |>
  group_by(species) |>
  mutate(cumedist = cume_dist(body_mass_g)) |>
ggplot(aes(x = body_mass_g, y = cumedist, color = species)) +
  geom_step(direction = 'vh') +
  scale_color_brewer(palette = 'Set2') +
  theme_minimal(base_size = 16)