# [R] panel order in xyplot

From: Antje Döring <Antje.Doering_at_komdat.com>
Date: Thu 22 Dec 2005 - 23:41:29 EST

Hi all,

I have a question concerning xyplot. My data is a data.frame looking like that:

In the first column I have numbers from 0 to 23 (hours of a day), the second column contains the name of a weekday (Day as factor) and the third column contains the number I am interested in. So as an example, the first five rows look like that:

Hour Day Freq

1 0 Mo 23

2 1 Mo 20

3 2 Mo 14

4 3 Mo 27

5 4 Mo 26

To read: On Monday between 0 and 1 o'clock 23 things happened.

The code of the xyplot looks like that:

trellis.device(new = FALSE, col = FALSE)

xyplot(Freq ~ Hour | Day, data = mydata,

xlab = "hour", ylab = "number", main = "xxx", ylim = 1:30,

scales = list(x = list(at = seq(0,24,6), labels = c(0, 6, 12, 18, 24), cex = 0.7, relation = "free"),

y = list(tick.number = 5, cex = 0.7)), between = list(x = 0.5, y = 1.5),

layout = c(4,2), aspect = 1,

panel = function(x,y){

panel.grid()

panel.barchart(x, y, horiz = F, aspect = 1, col = "red")

}

)

Now my problem:

The plot is ordered by default, that in the first row I can see Friday, Saturday and Sunday, in the second row there is Monday, Tuesday, Wednesday and Thursday. I like to order the panels that way that in the first row there should be Monday-Thursday, the last row to contain Friday - Sunday.

Is there any parameter in xyplot I can add to achieve this result? Any parameter where I can tell how the panels have to be arranged?

Thanks a lot for any help.

Antje

[[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list