Dear List-Members, I would like to produce a ordered boxplot in which the categories with the smallest median are plotted at the left end and the box with the largest median at the right. Thanks in advance for any advices Thomas H.
?reorder.factor shows the follwing example: bymedian <- with(InsectSprays, reorder(spray, count, median)) boxplot(count ~ bymedian, data = InsectSprays, xlab = "Type of spray", ylab = "Insect count", main = "InsectSprays data", varwidth = TRUE, col = "lightgray") Thomas Hoffmann wrote:> Dear List-Members, > > I would like to produce a ordered boxplot in which the categories with > the smallest median are plotted at the left end and the box with the > largest median at the right. > > Thanks in advance for any advices > Thomas H. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", at=with(InsectSprays, rank(tapply(count, spray, median)))) Chuck Cleland a ?crit :> ?reorder.factor shows the follwing example: > > bymedian <- with(InsectSprays, reorder(spray, count, median)) > > boxplot(count ~ bymedian, data = InsectSprays, > xlab = "Type of spray", ylab = "Insect count", > main = "InsectSprays data", varwidth = TRUE, > col = "lightgray") > > Thomas Hoffmann wrote: > >>Dear List-Members, >> >>I would like to produce a ordered boxplot in which the categories with >>the smallest median are plotted at the left end and the box with the >>largest median at the right. >> >>Thanks in advance for any advices >>Thomas H. >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >> > >-- ------------------------------------------------------------------- Jacques.Veslot at good.ibl.fr CNRS UMR 8090 - http://www-good.ibl.fr G?nomique et physiologie mol?culaire des maladies m?taboliques I.B.L 2eme etage - 1 rue du Pr Calmette, B.P.245, 59019 Lille Cedex Tel : 33 (0)3.20.87.10.44 Fax : 33 (0)3.20.87.10.31
you could use the 'at' argument of boxplot(), e.g., y <- c(sapply(c(10, -5, -10, 5, 0), rnorm, n = 100, sd = 1)) gr <- gl(5, 100, labels = LETTERS[1:5]) boxplot(y ~ gr, at = rank(tapply(y, gr, median))) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Thomas Hoffmann" <thomas.hoffmann at uni-bonn.de> To: <r-help at stat.math.ethz.ch> Sent: Thursday, April 27, 2006 10:36 AM Subject: [R] ordered boxplots> Dear List-Members, > > I would like to produce a ordered boxplot in which the categories > with > the smallest median are plotted at the left end and the box with the > largest median at the right. > > Thanks in advance for any advices > Thomas H. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm