pirateplot: pirateplot

Description Usage Arguments Examples

Description

The pirateplot function creates an RDI (Raw data, Descriptive and Inferential statistic) plot showing the relationship between 1 to 3 categorical independent variables and 1 continuous dependent variable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
pirateplot(formula = NULL, data = NULL, plot = TRUE,
  avg.line.fun = mean, pal = "basel", back.col = NULL, point.cex = NULL,
  point.pch = NULL, point.lwd = 1, jitter.val = 0.03, theme = 1,
  bean.b.o = NULL, bean.f.o = NULL, point.o = NULL, bar.f.o = NULL,
  bar.b.o = NULL, inf.f.o = NULL, inf.b.o = NULL, avg.line.o = NULL,
  gl.col = NULL, point.col = NULL, point.bg = NULL, bar.f.col = NULL,
  bean.b.col = NULL, bean.f.col = NULL, inf.f.col = NULL,
  inf.b.col = NULL, avg.line.col = NULL, bar.b.col = NULL,
  quant.col = NULL, avg.line.lwd = 4, bean.lwd = 1, bean.lty = 1,
  inf.lwd = NULL, bar.lwd = 1, at = NULL, bw = "nrd0", adjust = 1,
  add = FALSE, sortx = "alphabetical", cex.lab = 1, cex.axis = 1,
  quant = NULL, quant.length = NULL, quant.lwd = NULL,
  quant.boxplot = FALSE, bty = "o", evidence = FALSE, cap.beans = FALSE,
  family = NULL, inf.method = "hdi", inf.within = NULL, inf.p = NULL,
  hdi.iter = 1000, inf.disp = NULL, cut.min = NULL, cut.max = NULL,
  width.min = 0.3, width.max = NA, ylim = NULL, xlim = NULL,
  xlab = NULL, ylab = NULL, main = NULL, yaxt = NULL, xaxt = NULL,
  gl.lwd = NULL, gl.lty = NULL, bar.b.lwd = NULL, line.fun = NULL,
  line.o = NULL, inf.o = NULL, bean.o = NULL, inf.col = NULL,
  theme.o = NULL, bar.o = NULL, inf = NULL, hdi.o = NULL,
  inf.type = NULL, inf.band = NULL)

Arguments

formula

formula. A formula in the form y ~ x1 + x2 + x3 indicating the vertical response variable (y) and up to three independent variables

data

dataframe. A dataframe containing the variables specified in formula.

plot

logical. If TRUE (the default), thent the pirateplot is produced. If FALSE, the data summaries created in the plot are returned as a list.

avg.line.fun

function. A function that determines how average lines and bar heights are determined (default is mean).

pal

string. The color palette of the plot. Can be a single color, a vector of colors, or the name of a palette in the piratepal() function (e.g.; "basel", "google", "southpark"). To see all the palettes, run piratepal(palette = "all", action = "show")

point.cex, point.pch, point.lwd

numeric. The size, pch type, and line width of raw data points.

jitter.val

numeric. Amount of jitter added to points horizontally. Defaults to 0.05.

theme

integer. An integer in the set 0, 1, 2 specifying a theme (that is, new default values for opacities and colors). theme = 0 turns off all opacities which can then be individually specified individually.

bar.f.o, point.o, inf.f.o, inf.b.o, avg.line.o, bean.b.o, bean.f.o, bar.b.o

numeric. A number between 0 and 1 indicating how opaque to make the bars, points, inference band, average line, and beans respectively. These values override whatever is in the specified theme

gl.col, back.col

string. The color of the horizontal gridlines and plotting background.

point.col, bar.f.col, bean.b.col, bean.f.col, inf.f.col, inf.b.col, avg.line.col, bar.b.col, quant.col, point.bg

string. Vectors of colors specifying the colors of the plotting elements. This will override values in the palette. f stands for filling, b stands for border.

bean.lwd, bean.lty, inf.lwd, avg.line.lwd, bar.lwd

numeric. Vectors of numbers customizing the look of beans and lines.

at

integer. Locations of the beans. Especially helpful when adding beans to an existing plot with add = TRUE

bw, adjust

Arguments passed to density calculations for beans (see ?density)

add

logical. Whether to add the pirateplot to an existing plotting space or not.

sortx

string. How to sort the x values. Can be "sequential" (as they are found in the original dataframe), "alphabetical", or a string indicating a function (i.e.; "mean")

cex.lab, cex.axis

Size of the labels and axes.

quant

numeric. Adds horizontal lines representing custom quantiles.

quant.length, quant.lwd

numeric. Specifies line lengths/widths of quant.

quant.boxplot

logical. Should standard values be included?

bty, xlim, ylim, xlab, ylab, main, yaxt, xaxt

General plotting arguments

evidence

logical. Should Bayesian evidence be shown? (currently ignored)

cap.beans

logical. Should maximum and minimum values of the bean densities be capped at the limits found in the data? Default is FALSE.

family

a font family (Not currently in use)

inf.method

string. A string indicating what types of inference bands to calculate. "ci" means frequentist confidence intervals, "hdi" means Bayesian Highest Density Intervals (HDI), "iqr" means interquartile range, "sd" means standard deviation, "se" means standard error, "withinci" means frequentist confidence intervals in a within design (Morey, 2008).

inf.within

string. The variable which serves as an ID variable in a within design.

inf.p

numeric. A number adjusting how inference ranges are calculated. for "ci" and "hdi", a number between 0 and 1 indicating the level of confidence (default is .95). For "sd" and "se", the number of standard deviations / standard errors added to or subtracted from the mean (default is 1).

hdi.iter

integer. Number of iterations to run when calculating the HDI. Larger values lead to better estimates, but can be more time consuming.

inf.disp

string. How should inference ranges be displayed? "line" creates a classic vertical line, "rect" creates a rectangle, "bean" forms the inference around the bean.

cut.min, cut.max

numeric. Optional minimum and maximum values of the beans.

width.min, width.max

numeric. The minimum/maximum width of the beans.

gl.lwd, gl.lty

Customization for grid lines.

bar.b.lwd, line.fun, inf.o, bean.o, inf.col, theme.o, inf, inf.type, inf.band, bar.o, line.o, hdi.o

depricated arguments

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
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
58
59
60
61
62
63
64
65
66
67
68
69
70
# Default pirateplot of weight by Time
pirateplot(formula = weight ~ Time,
          data = ChickWeight)

# Same but in grayscale
pirateplot(formula = weight ~ Time,
          data = ChickWeight,
          pal = "gray")


# Now using theme 2
pirateplot(formula = weight ~ Time,
          data = ChickWeight,
          main = "Chicken weight by time",
          theme = 2) # theme 2

# theme 3
pirateplot(formula = weight ~ Time,
          data = ChickWeight,
          main = "Chicken weight by time",
          theme = 3) # theme 3

# theme 4
pirateplot(formula = weight ~ Time,
          data = ChickWeight,
          main = "Chicken weight by time",
          theme = 4) # theme 4

# Start with theme 2, but then customise!
pirateplot(formula = weight ~ Time,
          data = ChickWeight,
          theme = 2, # theme 2
          pal = "xmen", # xmen palette
          main = "Chicken weights by Time",
          point.o = .4, # Add points
          point.col = "black",
          point.bg = "white",
          point.pch = 21,
          bean.f.o = .2, # Turn down bean filling
          inf.f.o = .8, # Turn up inf filling
          gl.col = "gray", # gridlines
          gl.lwd = c(.5, 0)) # turn off minor grid lines

# 2 IVs
pirateplot(formula = len ~ dose + supp,
          data = ToothGrowth,
          main = "Guinea pig tooth length by supplement",
          point.pch = 16,  # Point specifications...
          point.col = "black",
          point.o = .7,
          inf.f.o = .9, # inference band opacity
          gl.col = "gray")


# Build everything from scratch with theme 0
#  And use 3 IVs
pirateplot(formula = height ~ headband + eyepatch + sex,
          data = pirates,
          pal = gray(.1), # Dark gray palette
          theme = 0, # Start from scratch
          inf.f.o = .7, # Band opacity
          inf.f.col = piratepal("basel"), # Add color to bands
          point.o = .1, # Point opacity
          avg.line.o = .8, # Average line opacity
          gl.col = gray(.6), # Gridline specifications
          gl.lty = 1,
          gl.lwd = c(.5, 0))

  # See the vignette for more details
 vignette("pirateplot", package = "yarrr")


Search within the yarrr package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.