The goal of butterfly is to produce (side-by-side and other) density plots
You can install the released version of butterfly from github with:
devtools::install_github("RaymondBalise/butterfly")
This is a basic example which shows you how to draw a butterfly plot.
library(butterfly)
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
#> Loading required package: ggplot2
#> Loading required package: ggthemes
butterfly(malesFemales1910$sex, malesFemales1910$age, "Census 1910")
butterfly(malesFemales2010$sex, malesFemales2010$age, "Census 2010",
infoHeight = 15, ageLimit = 110)
If you prefer a common shared axis consider using the butterfly_closed function
butterfly_closed(malesFemales2010$sex, malesFemales2010$age, "Census 2010")
butterfly_closed(malesFemales2010$sex, malesFemales2010$age, "Census 2010",
vertical=FALSE)
Please note that the ‘butterfly’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.