Order in barchart
I think you misunderstand what barchart does. It expects a formula, not a named vector, as its first argument. nm <- names(T3) z <- factor(nm, levels=nm) barchart(z ~ T3, xlab="Mean Values", col="dark blue") is probably what you are looking for. The factor z is constructed to be in the order you want. That barchart() accepts a named vector appears to be undocumented. For an unnamed vector it does not behave similarly to barplot().
On Mon, 2 Feb 2004, Bliese, Paul D MAJ USAMH wrote:
Sorry if this is a FAQ -- I checked the archives and help files, but was stumped. In the data T3 (provided below) the values are sorted from lowest to highest.
T3
10 7 19 13 5 3 15 18
2 24
2.650568 2.666237 2.731649 2.749221 2.777130 2.801124 2.804472 2.813891
2.838316 2.839654
36 20 25 32 26 12 14 29
23 6
2.843043 2.868335 2.882906 2.896539 2.922535 2.931397 2.939590 2.944353
2.983473 3.015235
39 4 17 9 30 21 33 22
8 35
3.017590 3.020495 3.038758 3.066808 3.084511 3.086072 3.106873 3.127783
3.167053 3.173310
28 16 37 1 31 40 27 11
34 38
3.173323 3.221106 3.236643 3.274417 3.274772 3.283696 3.307872 3.355327
3.382744 3.498301
If I use barchart in the trellis library, the bars are arranged by factor
order of the labels (1,10,11,12,etc.).
barchart(T3,xlab="Mean Values",col="dark blue")
Would it be possible to have the bars arranged from highest to lowest in terms of the values (2.65, 2.66, 2.73, etc.) as it is done in barplot?
barplot(T3,xlab="Mean Values",col="dark blue",horiz=T,cex.names=.5)
I would like to use barchart instead of barplot because of some of the additional features of the lattice library. Thanks, Paul
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595