Skip to content

ordered boxplots

4 messages · Thomas Hoffmann, Chuck Cleland, Jacques VESLOT +1 more

#
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:

  
    
#
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", 
at=with(InsectSprays, rank(tapply(count, spray, median))))

Chuck Cleland a ?crit :

  
    
#
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
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm