No reorder.factor in R

Wright, Kevin kevin.wright@pioneer.com
Mon, 9 Sep 2002 09:22:59 -0500


I was using R 1.5.1 today with an old script from S-Plus and discovered that
R does not have reorder.factor.  

It's a very simple function, but very handy for re-arranging factors in
lattice graphics (among other places).  Would it make sense to add this
function to the base code
in order to increase compatability with S-Plus and add additional
functionality?

reorder.factor <- function(fac, y, fun=mean, ...){
  ordered(fac, levels=levels(fac)[order(tapply(y, fac, fun, ...))])
}


Kevin Wright, Research Scientist
Pioneer Hi-Bred Int'l, x4054.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._