Skip to content
Back to formatted view

Raw Message

Message-ID: <OF5BE3B1BE.8E3CD22B-ON8025741D.00474539-8025741D.00481885@hsl.gov.uk>
Date: 2008-03-31T13:07:40Z
From: Richard Cotton
Subject: Reorder the x-axis using  lattice
In-Reply-To: <175717.40266.qm@hsl.gov.uk>

>    Is there a way to reorder the xaxis using lattice. Using the 
> following data, the x-axis is ordered as BP GH MH PF RE RP SF VT but
> I would like the x-axis to be ordered as PF RP BP GH VT SF RE MH.
> 
>     K?n         Skalor     Tillf?lle Medelv?rde
> 1  Kvinnor     BP 1-inskrivning   36.45283
> 2  Kvinnor     GH 1-inskrivning   38.62255
> 3  Kvinnor     MH 1-inskrivning   62.88889
> 4  Kvinnor     PF 1-inskrivning   39.80710

>   bwplot(Medelv?rde ~ Skalor| K?n , kt, panel = "panel.superpose",
>        groups = Tillf?lle,scales = list(x = list(rot = 45),cex=0.7,
> alternating=2),
> ...

When the x-axis is a factor, bwplot plots in order of the factor levels. 
You'll need to explicitly set the levels in your data frame:

Skalor <- factor(c("BP", "GH", "MH", "PF", "RE", "RP", "SF", "VT", "BP", 
"GH", "MH", "PF", "RE", "RP", "SF", "VT"), levels=c("PF", "RP", "BP", 
"GH", "VT", "SF", "RE", "MH"))
kt <- data.frame(Kon=Kon, Skalor=Skalor, ...)
bwplot(...) #as before

Regards,
Richie.

Mathematical Sciences Unit
HSL


r-help-bounces at r-project.org wrote on 31/03/2008 11:05:18:

> Dear list,
> 

> 5  Kvinnor     RE 1-inskrivning   41.50943
> 6  Kvinnor     RP 1-inskrivning   22.22222
> 7  Kvinnor     SF 1-inskrivning   59.19811
> 8  Kvinnor     VT 1-inskrivning   34.84568
> 9  Kvinnor     BP 2-utskrivning   43.14815
> 10 Kvinnor     GH 2-utskrivning   44.11321
> 11 Kvinnor     MH 2-utskrivning   77.22222
> 12 Kvinnor     PF 2-utskrivning   44.74280
> 13 Kvinnor     RE 2-utskrivning   68.95425
> 14 Kvinnor     RP 2-utskrivning   39.90385
> 15 Kvinnor     SF 2-utskrivning   64.62264
> 16 Kvinnor     VT 2-utskrivning   51.97531
> 
> 

>        panel.groups = "panel.linejoin",lty=c(1:3),lwd=3,
> col=c("steelblue","grey50","green4"),
>        ylab = list(label = "skalpo?ng (0-100)", cex = 0.8),
>        xlab = list(label = "skalor", cex = 0.8),
>        key = list(lines = 
> Rows(list(col=c("steelblue","grey50","green4"),lty=c(1:3)),
>                 c(1:3, 0)),cex=0.8,text = list(lab = as.
> character(unique(kt$Tillf?lle))),
>                   columns = 2, title = "SF-36: Skalpo?ng f?r 
> respektive k?n vid 3 m?ttillf?lle ",
>                   cex.title=0.9))
> 
>   Thanks in advance,
>   Tom
> 
> 
> ---------------------------------
> 
> J?mf?r pris p? flygbiljetter och hotellrum: http://shopping.yahoo.
> se/c-169901-resor-biljetter.html
>    [[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.

------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:21}}