boxplot2() function
added October 11, 2012
Code File
The code for the boxplot2() function is contained in the file boxplot2.R. You can source the file directly into R by calling
source("http://www.biostat.jhsph.edu/~pmurakam/boxplot2.R")The code is licensed under the GNU General Public License version 3, or (at your option) any later version.
Manual page
Description: A function to produce boxplots, stratified by the values of a second factor and distinguished by different colors. Usage: boxplot2(y, x, by, ylab=NULL, col=NULL, ...) Arguments: y - a numeric vector of data values to be split into groups according to the grouping variable x (usually a factor) x - the grouping variable (usually a factor) by which to split the numeric data y by - the second grouping variable by which to split the numeric data y ylab - ylab argument to boxplot() col - vector of colors, one for each unique value of by ... - additional arguments to pass to boxplot() See also: boxplot, stripchart, bwplot in the lattice package Examples: set.seed(5678) y = c(rnorm(20,2), rnorm(27,3), rnorm(23,0), rnorm(30,1)) x = factor(rep(c("a","b"),c(47,53))) by = factor(rep(c("group1","group2","group1","group2"),c(20,27,23,30))) boxplot2(y=y, x=x, by=by, ylab="y")