hist_bygroup: Plot and overlay histograms by group

Description Usage Examples

Description

A simple function to plot histograms by group, and overlay them. This is notoriously difficult to achieve in base R.

Usage

1
2
3
4
5
hist_bygroup(yvar, group, dataset, breaks = 25, what = c("counts",
  "density"), log = FALSE, col = palette(), xlab = NULL,
  ylab = "Nr. individuals", ylim = NULL, xlim = NULL,
  legend.text = NULL, legend.cex = 1, xaxis = NULL, overlay = TRUE,
  group.expression = NULL, ...)

Examples

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))

RemkoDuursma/plover documentation built on May 9, 2019, 9:39 a.m.