Box plot
boxPlot.Rd
Generate a box and whiskers plot.
Usage
boxPlot(
data = NULL,
name.variable = NULL,
name.value = NULL,
fill.variable = NULL,
fill.colours = NULL,
multi.panel = FALSE,
panel.variable = NULL,
errorbar = FALSE,
title = NULL,
subtitle = NULL
)
Arguments
- data
A
data.frame
ordata.table
of data to be plotted.- name.variable
character vector containing the the name of the column with values for the horizontal axis.
- name.value
character vector containing the name of the column with values for the vertical axis.
- fill.variable
Optional character vector indicating the name of the column for fill variable.
- fill.colours
Optional character vector of specified colours for the fill variable. It must have the same length of unique values in the
fill.variable
column.- multi.panel
Boolean. If TRUE different subplot panels are plot with (facet_wrap) identified by the values of the
panel.variable
argument. Default = FALSE.- panel.variable
Character vector with the column name of facet variable for multi.panel. If
multi.panel
is TRUE, this argument is mandatory.- errorbar
Boolean, if TRUE horizontal error bars on whiskers are plot. Default is FALSE.
- title
Optional character vector with title.
- subtitle
Optional character vector with subtitle.
Details
This function produces a box plot by using the ggplot2
library.
The result of the function is a ggplot
object which can be further customised with its
directives.
Examples
if (FALSE) {
# myData is a long format data.table with columns:
# city
# variable (which contains the score type ex: "rmse", "corr", "bias"
# value (which contains score values)
# We want to produce a "box and whiskers" plot with each site on the horizontal axis
# the score on the y axis and many subplots, one for each score.
boxPlot(data = myData, name.variable = "city", name.value = "value",
fill.variable = "city", colours = c("#83DB66","#773CD9"),
multi.panel=TRUE, panel.variable = "variable")
}