pointsOnBoxplot.default: Draw Points on Top of a Boxplot using Appropriate Shifting

Description Usage Arguments Value Author(s) Examples

View source: R/pointsOnBoxplot.R

Description

Draw Points on Top of a Boxplot using Appropriate Shifting

Usage

1
2
3
## Default S3 method:
pointsOnBoxplot(x = NULL, y = NULL, totalSpread = 0.3,
  roundTo = NULL, horizontal = FALSE, ...)

Arguments

x

vector of numeric values that were used to create boxplots

y

vector of values representing a categorical variable

totalSpread

total spread of point plotting range within a boxplot. Defaults to 0.3 so that points plot between 0.85 and 1.15

roundTo

optional rounding interval. For example, if given roundTo = 0.25, all numeric x values will be rounded to the nearest quarter

horizontal

logical indicating if the boxplots should be horizontal; default FALSE means vertical boxes.

...

further parameters to be passed to the points function

Value

points are drawn to the current device

Author(s)

Jason Waddell

Examples

 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
# Examples run in the formula and default methods
x2 <- runif(50, 0, 10);
table(customRound(x2, roundTo = 0.5))
boxplot(x2)
pointsOnBoxplot(x2, pch = 19, roundTo = 0.5)

# Set up input data
x <- c(sample(1:5, size = 25, replace = TRUE), rpois(25, lambda = 4))
colVec <- c(rep("olivedrab", 10), rep("red", 5), rep("goldenrod", 15),
    rep("red", 15), rep("olivedrab", 5))
y <- rep(c("Awesome Rats", "Stupid Rats"), each = 25)
y2 <- rep(c("Open", "Analytics"), 25)

x2 <- c(1, 2, 2, 3, 3, 1, 1, 1, 4, 5)
y3 <- c(rep("A", 5), rep("B", 5))
levels(y3) <- c("A", "B", "C")

boxplot(x ~ y, horizontal = TRUE)
pointsOnBoxplot(x ~ y, horizontal = TRUE)

boxplot(x ~ y)
pointsOnBoxplot(x = x, y = y, col = colVec, pch = 19, cex = 2)

boxplot(x ~ y + y2)
pointsOnBoxplot(x ~ y + y2, col = colVec, pch = 19, cex = 2)

oaPlots documentation built on May 2, 2019, 6:46 a.m.