mplot3_box: 'mplot3': Boxplot

View source: R/mplot3_box.R

mplot3_boxR Documentation

mplot3: Boxplot

Description

Draw boxplots of a vector (single box), data.frame (one box per column) or list (one box per element - good for variable of different length)

Usage

mplot3_box(
  x,
  col = NULL,
  alpha = 0.66,
  border = NULL,
  border.alpha = 1,
  group.spacing = 0.25,
  xlim = NULL,
  ylim = NULL,
  xlab = NULL,
  ylab = NULL,
  boxwex = NULL,
  staplewex = 0.5,
  horizontal = FALSE,
  main = NULL,
  groupnames = NULL,
  xnames = NULL,
  xnames.at = NULL,
  xnames.y = NULL,
  xnames.font = 1,
  xnames.adj = NULL,
  xnames.pos = NULL,
  xnames.srt = NULL,
  order.by.fn = NULL,
  legend = FALSE,
  legend.names = NULL,
  legend.position = "topright",
  legend.inset = c(0, 0),
  mar = NULL,
  oma = rep(0, 4),
  pty = "m",
  yaxis = TRUE,
  ylim.pad = 0,
  theme = rtTheme,
  labelify = TRUE,
  autolabel = letters,
  na.rm = TRUE,
  palette = rtPalette,
  par.reset = TRUE,
  pdf.width = 6,
  pdf.height = 6,
  filename = NULL,
  ...
)

Arguments

x

Vector, data.frame or list: Each data.frame column or list element will be drawn as a box

col

Vector of colors to use

alpha

Numeric: col transparency

border

Color for lines around boxes

border.alpha

Numeric: border transparency

group.spacing

Numeric: Spacing between groups of boxes (when input is data.frame or list)

xlim

Float vector, length 2: x-axis limits

ylim

Float vector, length 2: y-axis limits

xlab

Character: x-axis label

ylab

Character: y-axis label

boxwex

Numeric: Scale factor for box width. Default = .5

staplewex

Numeric: max and min line ("staple") width proportional to box. Default = .5

horizontal

Logical: If TRUE, draw horizontal boxplot(s).

main

Character: Plot title

groupnames

Character vector: Group names

xnames

Character vector: Names for individual boxes

xnames.at

Numeric: Position of xnames

order.by.fn

Character: "mean", "median" or any function that outputs a single number: E stimate function on each vector and order boxes (when input is data.frame or list) by ascending order. Default = NULL, i.e. no reordering

mar

Float, vector, length 4: Margins; see par("mar")

oma

Float, vector, length 4: Outer margins; see par("oma")

pty

Character: "s" gives a square plot; "m" gives a plot that fills graphics device size. Default = "m" (See par("pty"))

theme

Character: Run themes() for available themes

autolabel

Character vector to be used to generate autolabels when using rtlayout with autolabel = TRUE.

na.rm

Logical: If TRUE, remove NA values, otherwise function will give error. Default = TRUE

palette

Vector of colors, or Character defining a builtin palette - get options with rtpalette()

par.reset

Logical: If TRUE, reset par setting before exiting.

pdf.width

Float: Width in inches for pdf output (if filename is set).

pdf.height

Float: Height in inches for pdf output.

filename

Character: Path to file to save plot. Default = NULL

...

Additional arguments to graphics::boxplot

Details

Note that argument xnames refers to the x-axis labels below each box. If not specified, these are inferred from the input when possible. Argument xlab is a single label for the x-axis as per usual and often omitted if xnames suffice.

Author(s)

E.D. Gennatas

Examples

## Not run: 
## vector
x <- rnorm(500)
mplot3_box(x)

## data.frame - each column one boxplot
x <- data.frame(alpha = rnorm(50), beta = rnorm(50), gamma = rnorm(50))
mplot3_box(x)

## list of vectors - allows different length vectors
x <- list(alpha = rnorm(50),
          beta = rnorm(80, 4, 1.5),
          gamma = rnorm(30, -3, .5))
mplot3_box(x)

## grouped boxplots: input a list of lists. outer list: groups; inner lists: matched data vectors
x <- list(Cases = list(Weight = rnorm(50), Temperature = rnorm(45, 1)),
          Controls = list(Weight = rnorm(80), Temperature = rnorm(72)))
mplot3_box(x)

## End(Not run)

egenn/rtemis documentation built on Dec. 17, 2024, 6:16 p.m.