Split Boxplot by Group

Description

Plots a boxplot with each data split into sub-boxplots, defined according a factor variable.

The default method plots each column using one boxplot for each level in a factor.

The method for NMF-class objects plots use the data from the coefficient matrix.

Usage

boxplotBy(x, ...)

S3 (default)
`boxplotBy`(x, by, scale = FALSE, col = rainbow(nlevels(by)), legend = TRUE, 
  names = colnames(x), ...)

S3 (NMF)
`boxplotBy`(x, by, scale = FALSE, ...)

Arguments

x
data matrix, with samples in column. NB: in boxplot x has samples in rows.
by
grouping variable, coerced to a factor if necessary. It is recycled if not of length the number of columns in x
col
spcecifies the colour to use for each group by argument by.
legend
legend specification. If a logical, it turns on/off the legend, if a character string, it indicates the position of the legend, e.g. 'topright' (see legend for possible values).
...
extra arguments passed to the base boxplot function.
scale
logical that indicate if each data column should be scaled so that it sums up to one.
names
group labels which will be printed under each boxplot. Can be a character vector or an expression (see plotmath).

Examples


x <- rmatrix(3, 20)
boxplotBy(x, gl(2, 10))

plot of chunk unnamed-chunk-1


Author

This function was adapted from the following post on R-help: https://stat.ethz.ch/pipermail/r-help/2003-March/031046.html