A simple function to plot histograms by group, and overlay them. This is notoriously difficult to achieve in base R.
1 2 3 4 5 |
1 2 3 4 5 6 7 8 9 | library(wesanderson)
hist_bygroup(Petal.Length, Species, iris, col=wes_palette("Chevalier"), breaks=50)
hist_bygroup(Petal.Length, Species, iris, col=wes_palette("Chevalier"), breaks=50,
group.expression=abline(v=mean(Y), col=col.cur, lwd=2))
hist_bygroup(Petal.Length, Species, iris, col=wes_palette("Chevalier"), what="density",
breaks=40,
group.expression=curve(dnorm(x, mean(Y), sd=sd(Y)), add=T))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.