################################################################################ ## Copyright (C) 2012 Peter Murakami ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ################################################################################ ## Function to plot boxplots separately by a second factor, using different colors boxplot2 <- function(y, x, by, ylab=NULL, col=NULL, ...) { stopifnot(length(y)==length(x)) stopifnot(length(y)==length(by)) stopifnot(is.numeric(y)) un = unique(by) n = length(un) if(is.null(col)) { if(n<=12) { require(RColorBrewer) palette(brewer.pal(12,"Set3")) col = 1:n } else { stop("You must specify col with as many colors as there are unique values of by.") } } else { if(length(col)