knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Basic example using the mtcars
dataset.
library(ggBoxes) data(mtcars) p <- ggplot(mtcars, aes(x = wt, y = mpg, group = factor(cyl), color = factor(cyl), fill = factor(cyl))) + geom_boxplot2d() + theme(legend.position = 'bottom') p
We can add marginal density plots using the ggExtra
package. We have to add the raw data points for the marginal plots to display. By setting alpha = 0
the points are present for the density plots but are hidden from the plot.
ggExtra::ggMarginal(p + geom_point(alpha = 0), type = 'density', groupColour = TRUE, groupFill = TRUE)
library(palmerpenguins) data(penguins, package = 'palmerpenguins') ggplot(penguins, aes(x = flipper_length_mm, y = bill_length_mm, color = species, fill = species)) + geom_boxplot2d()
Persaud, N., & Yates, B. T. (complete 9-chapter book manuscript submitted for hopefully final review 2022 March 25). Cost-inclusive evaluation: Planning it, doing it, using it. Book manuscript already under contract. New York, NY: Guilford Press.
Tukey, John W. (1977). Exploratory Data Analysis. Addison-Wesley.
Wickham. H. (2016). ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.