prepare_tufte_: Preparation of a point and two lineranges for a boxplot...

View source: R/tufte_boxplot.R

prepare_tufte_R Documentation

Preparation of a point and two lineranges for a boxplot variant of Tufte

Description

This function prepares the elements necessary to draw a variant of the boxplot proposed by Edward Tufte.

Usage

prepare_tufte_(x = ~"", ymin, lower, middle, upper, ymax, ...)

Arguments

x

one-sided formula with the name of the variable to be plotted on the x-axis

ymin

one-sided formula with the column with the minimum value of y to be plotted

lower

one-sided formula with the column with the lower part of the "box" of the boxplot

middle

one-sided formula with the column with the middle point of the boxplot (usually the median)

upper

one-sided formula with the column with the upper part of the "box" of the boxplot

ymax

one-sided formula with the column with the column with the maximum value of y to be plotted

...

other aesthetic mappings created by aes_, passed to the geom_point element.

Value

a list with three elements: two geom_lineranges and a geom_point.

See Also

prepare_tufte which does quite the same things but, instead of one-sided formulas, uses character strings to set aesthetic mappings.

Examples

data("c02_14")
l <- prepare_tufte_(x = ~sesso, ymin = ~p10, lower = ~p25, middle = ~p50, 
                    upper = ~p75, ymax = ~p90)
tufte_boxplot(data = c02_14[1, ], l)

l
str(l)

# With respect to `prepare_tufte`, `prepare_tufte_` easily allows to express  
# `x` as a transformation of a column. Of particular interest the usage of
# `reorder`. For example, we can do a boxplot for each group, and sort the
# data by the median wage of the group:
l <- prepare_tufte_(x = ~reorder(id, p50), ymin = ~p10, lower = ~p25, middle = ~p50, 
                    upper = ~p75, ymax = ~p90, color = ~sesso)
tufte_boxplot(data = c02_14, l)
tufte_boxplot(data = c02_14, l) + ggplot2::coord_flip()


gibonet/ggstrusi documentation built on Jan. 13, 2024, 4:13 a.m.