[R] Lattice: reversing order of panel placement in conditional histograms

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Jul 23 09:38:03 CEST 2005

>From what I understand, you want to set up a factor with the levels 
reversed.  It is not that `5 is larger than 1', but that you created a 
factor with the levels in alphabetic order.  Lattice plots in the order of 
the levels.

Something like  f <- factor(f, levels=rev(levels(f))) will do this.

For the horizontal factor, give the levels in the order you want them to 
appear (which might not be the reverse of alphabetic).

On Sat, 23 Jul 2005, Sam Ferguson wrote:

> I have a question about lattice in general, and histogram specfically. 
> How do you control the ordering of factors that controls the placement 
> of the conditional panels. I have a dataset with factors that go 
> 'Q1','Q2',"Q3','Q5' and of course I want the plot to place Question Q1 
> at the top and Question Q5 at the bottom of the graphical output. 
> histogram() does the opposite as 5 is larger than 1. Similarly my 
> 'AlertFormat' factor is a textual category, and I need the data to read 
> from left to right (representing old to new) , with 'New A & V' on the 
> right, and 'Pre-existing A & V' on the left, which is the opposite to 
> how histogram plots.
> The current lattice output from what's below is here:- 
> http://www.arch.usyd.edu.au/~sfer9710/latticeoutput.pdf
> All I really want to do is reverse the placement entirely from what I 
> have received above.
> I've checked the help to no avail, and have looked through the r-help 
> archive. I love lattice, but always have problems of this nature. I hope 
> someone can help me solve them.

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

More information about the R-help mailing list