Skip to main content

Module helpers

Module helpers 

Source
Expand description

ggplot2’s helper functions (#414): discretising a continuous variable (cut_interval, cut_number, cut_width), resolution, and the stat_summary summary functions (mean_se, mean_cl_normal, mean_cl_boot, mean_sdl, median_hilow) as plain functions.

Structs§

Cut
A discretised variable: one interval label per input value (Value::Na for missing / non-finite input) and the interval labels in order — use values as a group / fill column and levels for the scale order.
CutWidth
Options for cut_width: at most one of center / boundary, and which side of each interval is closed.

Functions§

cut_interval
n intervals of equal width over the range of x — ggplot2’s cut_interval(x, n).
cut_interval_length
Intervals of width length on a grid of multiples of length covering x — ggplot2’s cut_interval(x, length = …).
cut_number
n intervals with (about) equal numbers of observations — ggplot2’s cut_number(x, n) (R type-7 quantile breaks).
cut_width
Intervals of width width — ggplot2’s cut_width(x, width, center, boundary, closed).
mean_cl_boot
Mean with a percentile-bootstrap interval from b resamples (mean_cl_boot(x, conf.int, B); seeded, so reproducible — but not R’s random stream).
mean_cl_normal
Mean with a Student-t confidence interval (mean_cl_normal(x, conf.int)).
mean_sdl
Mean ± mult standard deviations (mean_sdl(x, mult), default 2).
mean_se
(y, ymin, ymax) = mean ± mult standard errors (mean_se(x, mult)).
median_hilow
Median with the outer (1 ± conf_int) / 2 sample quantiles (median_hilow(x, conf.int)).
resolution
The smallest non-zero gap between the (unique) values of x — ggplot2’s resolution(x, zero); zero = true also counts the distance to 0. Constant data → 1.