A denstogram is a density plot, with some more info (the ecdf) to be displayed as a tooltip and the breaks of the axis showing quantiles.

denstogram(
  data,
  xvar,
  fillvar = NULL,
  facets_rows = NULL,
  facets_cols = NULL,
  facets_grid_wrap = c("grid", "wrap"),
  facets_scales = "fixed",
  facets_ncol = NULL,
  facets_nrow = NULL,
  trans = scales::identity_trans(),
  probs = c(0, 0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 1),
  na.rm = TRUE,
  summary_geom = c("none", "line", "text", "both"),
  summary_fn = function(x) stats::median(x, na.rm = na.rm),
  yaxis_title = "Density",
  xaxis_title = "",
  plotly = TRUE
)

Arguments

data

data to plot

xvar

var to plot

fillvar

variable to fill denstogram by

facets_rows

variable to facet the denstogram by

facets_cols

variable to facet the denstogram by

facets_grid_wrap

whether to use a "grid" or "wrap" in facetting

facets_scales

passed to facets

facets_ncol

cols for facets

facets_nrow

rows for facets

trans

transformation to apply from the scales package

probs

quantiles to include in the plot

na.rm

logical; if TRUE, missing values are removed from x. If FALSE any missing values cause an error.

summary_geom

which geom to add to the plot, to display a summary indicator calculated by summary_fn

summary_fn

function to calculate a summary indicator. Must receive one numeric vector and return a numeric vector of length 1

yaxis_title

character vector length 1

xaxis_title

character vector length 1

plotly

whether to convert it to an interactive plot using plotly

Value

ggplot object

Examples

denstogram(data = ggplot2::diamonds, xvar = price)
denstogram(data = ggplot2::diamonds, xvar = price, fillvar = color)
denstogram(data = ggplot2::diamonds, xvar = price, fillvar = cut)
denstogram(data = ggplot2::diamonds, xvar = price, facets_rows = cut)
denstogram(data = ggplot2::diamonds, xvar = price, facets_rows = cut, facets_grid_wrap = "wrap")
denstogram(data = ggplot2::diamonds, xvar = price, facets_rows = cut, facets_cols = color)
denstogram(data = ggplot2::diamonds, xvar = price, facets_rows = cut, facets_cols = color, facets_grid_wrap = "wrap")
denstogram(data = ggplot2::diamonds, xvar = price, fillvar = cut, facets_row = color)