File: layer_boxplots.Rd

package info (click to toggle)
r-cran-ggvis 0.4.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,716 kB
  • sloc: javascript: 7,373; sh: 25; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 2,276 bytes parent folder | download | duplicates (3)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/layer_boxplots.R
\name{layer_boxplots}
\alias{layer_boxplots}
\title{Display data with a boxplot.}
\usage{
layer_boxplots(vis, ..., coef = 1.5, width = NULL)
}
\arguments{
\item{vis}{Visualisation to modify}

\item{...}{Visual properties used to override defaults.}

\item{coef}{The maximum length of the whiskers as multiple of the
inter-quartile range. Default value is 1.5.}

\item{width}{Width of each bar. When x is continuous, this controls the width
in the same units as x. When x is categorical, this controls the width as a
proportion of the spacing between items (default is 0.9).}
}
\description{
This will add boxplots to a plot. The action of \code{layer_boxplots} depends
on whether the \code{x} prop is continuous or categorical.
}
\details{
The upper and lower "hinges" correspond to the first and third quartiles (the
25th and 75th percentiles). This differs slightly from the method used by the
\code{boxplot} function, and may be apparent with small samples. See
\code{\link{boxplot.stats}} for more information on how hinge positions are
calculated for \code{boxplot}.

The upper whisker extends from the hinge to the highest value that is within
1.5 * IQR of the hinge, where IQR is the inter-quartile range, or distance
between the first and third quartiles. The lower whisker extends from the
hinge to the lowest value within 1.5 * IQR of the hinge. Data beyond the end
of the whiskers are outliers and plotted as points (as specified by Tukey).
}
\examples{
library(dplyr)

mtcars \%>\% ggvis(~factor(cyl), ~mpg) \%>\% layer_boxplots()
# Set the width of the boxes to half the space between tick marks
mtcars \%>\% ggvis(~factor(cyl), ~mpg) \%>\% layer_boxplots(width = 0.5)

# Continuous x: boxes fill width between data values
mtcars \%>\% ggvis(~cyl, ~mpg) \%>\% layer_boxplots()
# Setting width=0.5 makes it 0.5 wide in the data space, which is 1/4 of the
# distance between data values in this particular case.
mtcars \%>\% ggvis(~cyl, ~mpg) \%>\% layer_boxplots(width = 0.5)

# Smaller outlier points
mtcars \%>\% ggvis(~factor(cyl), ~mpg) \%>\% layer_boxplots(size := 20)
}
\seealso{
\code{\link{compute_boxplot}} for more information on how data is
  transformed.
}