Skip to content

Calculate Weighted and Unweighted ECDFs for ggplot2

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

malcolmbarrett/ggecdf

Repository files navigation

ggecdf

R-CMD-check Codecov test coverage

The goal of ggecdf is to easily create weighted and unweighted empirical cumulative distributions (ECDFs) in ggplot2

Installation

You can install the development version of ggecdf from GitHub with:

# install.packages("devtools")
devtools::install_github("malcolmbarrett/ggecdf")

Example

geom_ecdf() allows you to create ECDFs based on ggplot’s stat_ecdf()

library(ggecdf)
library(ggplot2)
# dataset with weights
nhefs_weights <- tidysmd::nhefs_weights

ggplot(
  nhefs_weights,
  aes(x = smokeyrs, color = factor(qsmk))
) +
  geom_ecdf() +
  xlab("Smoking Years") +
  ylab("Proportion <= x (unweighted)")

Additionally, geom_ecdf() supports a weights aesthetic to calculate weighted ECDFs. For instance, here’s the same variables weighted by an ATO weight:

ggplot(
  nhefs_weights,
  aes(x = smokeyrs, color = factor(qsmk))
) +
  geom_ecdf(aes(weights = w_ato)) +
  xlab("Smoking Years") +
  ylab("Proportion <= x (weighted)")

About

Calculate Weighted and Unweighted ECDFs for ggplot2

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages