Description Usage Arguments Details Examples
Wrapper for ggplot() + geom_boxplot() visualisations
1 2 3 |
measure |
The measure of interest. The continuous variable from which the box plots are drawn. |
dimension |
The dimension separates the several box plots of the visualisation. It also defines the color of each box plot. |
dataframe |
An optional dataframe. If a dataframe is provided, all variables (measure and dimension) must be columns of the dataframe. |
alpha |
The transparency of the fill of the box plots. Alpha does not affect the lines of the box plots. |
notch |
If true (default) notchs are added to the boxplots. |
title |
The title of the plot |
measure_label |
The measure (y axis) label. If not used, the name of the variable passed to the measure parameter is used. |
dimension_label |
The dimension (x axis) label. If not used, the name of the variable passed to the dimension parameter is used. |
facet_formula |
The formula to create facet grids on ggplot. |
This function allows the creation of box plots in one line. It handles color automatically, according to the dimension given. The box plot always needs a measure and a dimension.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Set the seed
set.seed(1714)
# Create the variables
my_measure = rnorm(1000) + rep(c(0, 1.1, 1.2, 1.4, 1.8), 200)
my_dimension = as.factor(rep(c("A", "B", "C", "D", "E"), 200))
my_facet = as.factor(rep(c("One", "Another"), 500))
my_dataframe = data.frame(x = my_dimension, y = my_measure, f = my_facet)
# Test single vector
box_plot(measure = my_measure,
dimension = my_dimension,
title = "Simple box plot")
# Wait for key stroke
key_stroke = readline(prompt = 'Press Enter to continue...')
# Test dataframe and labels
box_plot(measure = y,
dimension = x,
dataframe = my_dataframe,
title = "Dataframe, labels and facets",
measure_label = "Values",
dimension_label = "Dimensions",
facet_formula = ~f)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.