Sam Ferguson
2005-Jul-23 04:22 UTC
[R] Lattice: reversing order of panel placement in conditional histograms
Hi R-people, 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. Thanks heaps -- Sam> version_ platform powerpc-apple-darwin7.9.0 arch powerpc os darwin7.9.0 system powerpc, darwin7.9.0 status Patched major 2 minor 1.0 year 2005 month 05 day 12 language R> aaRatingsQuestion X.Alert.Format. Response 1 Q1 New A & V 3 2 Q1 New A & V 3 3 Q1 New A & V 3 4 Q1 New A & V 3 5 Q1 New A, Pre-existing V 3 6 Q1 New A, Pre-existing V 3 7 Q1 New A, Pre-existing V 2 8 Q1 New A, Pre-existing V 2 9 Q1 New V, Pre-existing A 3 10 Q1 New V, Pre-existing A 2 11 Q1 New V, Pre-existing A 2 12 Q1 New V, Pre-existing A 2 13 Q1 Pre-existing A & V 1 14 Q1 Pre-existing A & V -2 15 Q1 Pre-existing A & V -2 16 Q1 Pre-existing A & V -2 17 Q2 New A & V 3 18 Q2 New A & V 3 19 Q2 New A & V 3 20 Q2 New A & V 3 21 Q2 New A, Pre-existing V 3 22 Q2 New A, Pre-existing V 2 23 Q2 New A, Pre-existing V 2 24 Q2 New A, Pre-existing V 1 25 Q2 New V, Pre-existing A 3 26 Q2 New V, Pre-existing A 2 27 Q2 New V, Pre-existing A 2 28 Q2 New V, Pre-existing A 2 29 Q2 Pre-existing A & V 1 30 Q2 Pre-existing A & V -2 31 Q2 Pre-existing A & V -2 32 Q2 Pre-existing A & V -2 33 Q3 New A & V 3 34 Q3 New A & V 3 35 Q3 New A & V 3 36 Q3 New A & V 3 37 Q3 New A, Pre-existing V 3 38 Q3 New A, Pre-existing V 3 39 Q3 New A, Pre-existing V 3 40 Q3 New A, Pre-existing V 2 41 Q3 New V, Pre-existing A 3 42 Q3 New V, Pre-existing A 3 43 Q3 New V, Pre-existing A 3 44 Q3 New V, Pre-existing A 2 45 Q3 Pre-existing A & V 2 46 Q3 Pre-existing A & V 1 47 Q3 Pre-existing A & V -2 48 Q3 Pre-existing A & V -3 49 Q5 New A & V 3 50 Q5 New A & V 3 51 Q5 New A & V 3 52 Q5 New A & V 3 53 Q5 New A, Pre-existing V 3 54 Q5 New A, Pre-existing V 3 55 Q5 New A, Pre-existing V 1 56 Q5 New A, Pre-existing V 1 57 Q5 New V, Pre-existing A 3 58 Q5 New V, Pre-existing A 2 59 Q5 New V, Pre-existing A 2 60 Q5 New V, Pre-existing A 2 61 Q5 Pre-existing A & V 1 62 Q5 Pre-existing A & V -1 63 Q5 Pre-existing A & V -1 64 Q5 Pre-existing A & V -3> attach(aaRatings) > histogram(Response|X.Alert.Format.+Question,type="count",nint=8)
Prof Brian Ripley
2005-Jul-23 07:38 UTC
[R] Lattice: reversing order of panel placement in conditional histograms
>From what I understand, you want to set up a factor with the levelsreversed. 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