Re: [R] Reorder the x-axis using lattice

From: <Richard.Cotton_at_hsl.gov.uk>
Date: Mon, 31 Mar 2008 14:07:40 +0100


> 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}}

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. Received on Mon 31 Mar 2008 - 13:09:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 31 Mar 2008 - 14:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive