Hi Hannah, I have run both the original code and the code copied from the email and both seem to work just fine. I don't know why you are getting that error message. Do you have both ggplot2 and reshape2 loaded? Still that should not give you the error message you are getting. In fact given the data I supplied, I just don't understand what it is trying to say. I cannot even find a function [1]rq.fit.br. Perhaps some other library that you have loaded is masking something in ggplot2 or reshape2. Can any more savvy R users comment here? Here is a link to the output which I think sounds like what you want.
[2]http://www.mediafire.com/i/?sgc2evfen5vvckb It only has two columns of data since I'm too lazy to do more but in principle it does any number as along at the output device can show it. Here is my sessionInfo() in case we have some serious differences in settings. sessionInfo() R version 2.15.1 (2012-06-22) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] reshape2_1.2.1 ggplot2_0.9.1 loaded via a namespace (and not attached): [1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 grid_2.15.1 [5] labeling_0.1 MASS_7.3-18 memoise_0.1 munsell_0.3 [9] plyr_1.7.1 proto_0.3-9.2 RColorBrewer_1.0-5 scales_0.2.1 [13] stringr_0.6 John Kane Kingston ON Canada -----Original Message----- From: hannah....@gmail.com Sent: Fri, 29 Jun 2012 21:31:55 -0400 To: jrkrid...@inbox.com Subject: Re: [R] Help Hi Petr, David and John, Thanks for the reply. I am sorry that I did not make it very clear. "One on top of another" may not be the right expression. Actually what I wanted is the second option of David's. There are 10 columns in the plot and, in each column, there are three boxplots. Different colors can be used to distinguish the three boxplots in the same column. John, when I run the code, I got the message below: Error in [3]rq.fit.br(x, y, tau = tau, ...) : Singular design matrix In addition: Warning message: In [4]is.na(rows) : [5]is.na() applied to non-(list or vector) of type 'NULL' Thanks again, everyone. Hannah 2012/6/29 John Kane <[6]jrkrid...@inbox.com> I think I may understand what you want. I 'd say the first thing to do is to combine the 3 matrices into a single data frame with a column for the values of A, B C Here is a mock-up with something like what I mean. I just used two columns of data for the mock-up. Then, you can reshape the data using melt() from the reshape2 package and then graph the data using ggplot from the ggplot2 package. Is this something like what you want? ============================================================= library(ggplot2) library(reshape2) A <- data.frame( m = (rep("A", 10)) , b=rnorm(10), c = rnorm(10)) B <- data.frame( m = (rep("B", 10)) , b=rnorm(10), c = rnorm(10)) C <- data.frame( m = (rep("C", 10)) , b=rnorm(10), c = rnorm(10)) mydata <- rbind( A, B, C ) names(mydata) <- c( "group", "k1", "k2" ) mdata <- melt(mydata) p <- ggplot( mdata , aes(variable, value , colour = variable )) + geom_boxplot() + facet_grid( group ~ .) p ============================================================== John Kane Kingston ON Canada > -----Original Message----- > From: [7]hannah....@gmail.com > Sent: Thu, 28 Jun 2012 16:29:54 -0400 > To: [8]r-help@r-project.org > Subject: [R] Help > > Dear all, > I need some help on plotting multiple boxplots on one figure. > I have three matrix A, B and C. Each of them is a 1000 by 10 matrix. > The 10 columns of all three matrix correspond to the > 10 values of the same parameter, say k=1, ..., 10. > I want to make a plot where x axis represents different values of k. > For each k value, I want to plot three boxplots, one on top of another. > For example, for k=1, I want to draw three boxplot based on the first > column of A, B and C respectively. Similarly, I do the same for the rest > of > k values. > Can some one give me some hint on this? > Thank you so much. > Hannah > > [[alternative HTML version deleted]] > > ______________________________________________ > [9]R-help@r-project.org mailing list > [10]https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > [11]http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit [12]http://www.inbox.com/photosharing to find out more! _________________________________________________________________ Get Free 5GB Email – Check out spam free email with many cool features! Visit [13]http://www.inbox.com/email to find out more! References 1. http://rq.fit.br/ 2. http://www.mediafire.com/i/?sgc2evfen5vvckb 3. http://rq.fit.br/ 4. http://is.na/ 5. http://is.na/ 6. mailto:jrkrid...@inbox.com 7. mailto:hannah....@gmail.com 8. mailto:r-help@r-project.org 9. mailto:R-help@r-project.org 10. https://stat.ethz.ch/mailman/listinfo/r-help 11. http://www.R-project.org/posting-guide.html 12. http://www.inbox.com/photosharing 13. http://www.inbox.com/email ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.