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

Deepayan Sarkar deepayan.sarkar at gmail.com
Mon Jul 25 20:19:47 CEST 2005


On 7/23/05, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> >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.

One additional comment: if you think top to bottom is the natural
order (which lattice doesn't), try using

as.table = TRUE

Deepayan

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

[...]




More information about the R-help mailing list