[R] ordering a factor in boxplot output

S Ellison S.Ellison at lgc.co.uk
Thu May 1 15:08:17 CEST 2008


The factor order defaults to alphabetical, and boxplot follows that.
Re-ordering the factor to the order of interest is probably the best way
of handling it. 

However, if you don;t want to do that, you could perhaps also use the
at= parameter in boxplot. For example

x<-rnorm(50)
g<-factor(rep(c("B","A"),each=25))

boxplot(x~g)

boxplot(x~g, at=c(2,1))

Steve E

>>> Tubin <sredmonson at yahoo.com> 30/04/2008 19:40:08 >>>

I'm sure I'm missing something obvious in the documentation...

I'm generating a boxplot 
boxplot(CleanValue~ApptCategory*ReportingCode,data=newfile)
where ApptCategory is a factor with possible values
("New","Established")

Problem is, the output orders those factors alphabetically, and I'd
really
rather see New come first. I'm apparently confused by the "reorder"
function
because somehow my attempts to apply it have resulted in reversing the
labelling (so now the established boxes are labelled as new).

What am I missing?  Thanks.
-- 
View this message in context:
http://www.nabble.com/ordering-a-factor-in-boxplot-output-tp16989073p16989073.html

Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at 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.

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list