Here's one way - you can reorder the levels of a factor variable by
specifying
the levels the way you want them.
> require("lattice")
Loading required package: lattice> bwplot( conc ~ Type : Treatment, data = CO2 )
> str(CO2$Type)
Factor w/ 2 levels "Quebec","Mississippi": 1 1 1 1 1 1 1 1
1 1 ...>
> str(CO2$Treatment)
Factor w/ 2 levels "nonchilled","chilled": 1 1 1 1 1 1 1 1
1 1 ...> ?bwplot
> CO2 <- CO2 ## Make a copy in the global environment
> CO2$Type2 <- factor(as.character(CO2$Type), levels =
c("Mississippi", "Quebec"))
> with(CO2, table(Type, Type2))
Type2
Type Mississippi Quebec
Quebec 0 42
Mississippi 42 0> quartz() ## Your plot window type here (quartz() works on a Mac)
> bwplot( conc ~ Type : Treatment, data = CO2 )
> quartz()
> bwplot( conc ~ Type2 : Treatment, data = CO2 )
>
Steven McKinney
Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On
Behalf Of Eck, Bradley J [brad.eck at mail.utexas.edu]
Sent: July 23, 2010 10:02 AM
To: r-help at r-project.org
Subject: [R] re-ordering bwplot
Dear list:
I'm using bwplot to compare concentrations by location and treatment as in:
# using built in data
bwplot( conc ~ Type : Treatment, data = CO2 )
I would like the order of the plots to be: 3,4,1,2. I can't seem to figure
this out with index.cond or permc.cond.
Any help is appreciated!
Brad Eck
[[alternative HTML version deleted]]
______________________________________________
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.