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

View source: R/tufte_boxplot.R

prepare_tufteR 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

character string with the name of the variable to be plotted on the x-axis

ymin

name of the column with the minimum value of y to be plotted

lower

name of the column with the lower part of the "box" of the boxplot

middle

name of the column with the middle point of the boxplot (usually the median)

upper

name of the column with the upper part of the "box" of the boxplot

ymax

name of the column with the maximum value of y to be plotted

...

other aesthetic mappings created by aes_string, 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 character arguments, uses one-sided formula 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 of the first row of the data:
tufte_boxplot(data = c02_14[1, ], l)

# Tufte boxplot of the first three rows:
tufte_boxplot(data = c02_14[1:3, ], l)

l
str(l)

# An example where we plot boxplots for each group:
l <- prepare_tufte(x = "id", ymin = "p10", lower = "p25",
                              middle = "p50", upper = "p75", ymax = "p90")
tufte_boxplot(data = c02_14[1, ], l)

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