uni.boxplots: Univariate boxplots

View source: R/02_data_preparation.R

uni.boxplotsR Documentation

Univariate boxplots

Description

The uni.boxplots function draws, within a single panel, an independent boxplot for each numeric (continuous or discrete) variable in a given dataset. It is particularly useful for data exploration (e.g. Zuur et al., 2010). For instance, to simultaneously observe the distributions of all numeric variables or to detect their univariate outliers.

Usage

uni.boxplots(
  dataset,
  MAR = c(0.5, 4.1, 1.1, 1.5),
  CEX.LAB = 1,
  FONT.LAB = 2,
  BTY = "n",
  FG = "gray35",
  COL.AXIS = "gray35",
  COL.LAB = "gray20",
  CEX.PAR = 0.8,
  TCL = -0.3,
  MGP = c(2.4, 0.6, 0),
  OMA = c(1, 0, 0, 0),
  TYPE = "n",
  BORDER = "lightcoral",
  COL = "moccasin",
  LTY = 1,
  STAPLEWEX = 0,
  WHISKLWD = 2,
  BOXWEX = 0.7,
  BOXLWD = 0.1,
  MEDLWD = 2.6,
  PCH = 19,
  ...
)

Arguments

dataset

The input dataset containing all variables to be plotted. It may contain all kinds of variables, the uni.boxplots function will automatically detect and plot numeric variables (columns).

MAR

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. The default is c(0.5,4.1,1.1,1.5).

CEX.LAB

The magnification to be used for x and y labels relative to the current setting of cex.

FONT.LAB

The font to be used for x and y labels.

BTY

A character string which determined the type of box which is drawn about plots. If BTY is one of "o", "l", "7", "c", "u", or "]" the resulting box resembles the corresponding upper case letter. A value of "n" suppresses the box (the default).

FG

The color to be used for the foreground of plots. This is the default color used for things like axes and boxes around plots (defaults to "gray35").

COL.AXIS

The color to be used for axis annotation. Defaults to "gray35".

COL.LAB

The color to be used for x and y labels. Defaults to "gray20".

CEX.PAR

A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default (for par, the panel manager). This starts as 1 when a device is opened, and is reset when the layout is changed, e.g. by setting mfrow. Defaults to 0.8.

TCL

The length of tick marks as a fraction of the height of a line of text. The default value is -0.3.

MGP

The margin line (in mex units) for the axis title, axis labels and axis line. Note that mgp[1] affects title whereas mgp[2:3] affect axis. The default is c(2.4, 0.6, 0).

OMA

A vector of the form c(bottom, left, top, right) giving the size of the outer margins in lines of text.

TYPE

The type of boxplot to draw. Default is "n".

BORDER

An optional vector of colors for the outlines of the boxplots. The values in border are recycled if the length of border is less than the number of plots. Default is "lightcoral".

COL

If col is non-null it is assumed to contain colors to be used to colour the bodies of the boxplots. Default is "moccasin".

LTY

The line type. Line types can either be specified as an integer (0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash) or as one of the character strings "blank", "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash", where "blank" uses ‘invisible lines’ (i.e., does not draw them).

STAPLEWEX

Staple line width expansion, proportional to box width. Default is 0.

WHISKLWD

Whisker line width expansion. Default is 2.

BOXWEX

A scale factor to be applied to all boxes. When there are only a few groups, the appearance of the plot can be improved by making the boxes narrower. Default is 0.7.

BOXLWD

Width of boxplot outer lines. Default is 0.1.

MEDLWD

Width of the median line. Default is 2.6.

PCH

The type of points to be drawn for outliers. Default is 19. See points for possible values and their interpretation.

...

Any other parameter that can be incorporated in boxplot.

Details

The uni.boxplots function only modifies the graphical parameters of the boxplot function in the graphics package to match some predefined preferences. Therefore, default values of uni.boxplots create nice looking boxplots but retain default heuristic aspects of boxplot (such as the length of whiskers or the plotting of outliers). These aspects can however be changed as in boxplot.
On the other hand, panel parameters are internally controlled using par. However, to avoid unforeseen conflicts with other internal parameters, it is not possible to tune panel parameters as we would do with par. Instead, parametrization is only possible with the given subset of parameters.

Value

A panel of univariate boxplots.

Note

To avoid recursive argument errors, internal arguments should be called using upper case letters (e.g. CEX.LAB = 0.9) whereas other arguments from the boxplot function should be called with their normal case writing (e.g. outline = FALSE)!

Examples

data("mtcars")
uni.boxplots(dataset = mtcars)

mrelnoob/jk.dusz.tarping documentation built on July 31, 2023, 9:19 a.m.