knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of ggecdf is to easily create weighted and unweighted empirical cumulative distributions (ECDFs) in ggplot2
You can install the development version of ggecdf from GitHub with:
# install.packages("devtools") devtools::install_github("malcolmbarrett/ggecdf")
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)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.