[R] Graph Order in xyplot

From: Sam Albers <tonightsthenight_at_gmail.com>
Date: Tue, 01 Jul 2008 15:20:13 -0700


I have constructed a Trellis style xyplot.

lengthf <- factor(length)
xyplot(SLI$velocity ~ SLI$width | SLI$lengthf, layout = c(2,7), xlab =

"Width (cm)", ylab = "Velocity (m/s^2)", col = "black")

This produces a lovely little plot. However, the grouping factor(lengthf) isn't in the right order. My values range from 2-28 and the 2 graph on the bottom left and the graphs continue sequentially left to right to the top of the page. I would like to have the 2 at the top and have the graphs shown in descending order (i.e. have the entire graph read like a book)

I tried the following but it didn't seem to work.

lengthd <-sort(SLI$length, decreasing =TRUE) lengthdf <- factor(SLI$lengthd)

Then I plotted the graph again:
xyplot(SLI$velocity ~ SLI$width | SLI$lengthdf, layout = c(2,7), xlab =
"Width (cm)", ylab = "Velocity (m/s^2)", col = "black")

This simply gave me the same graph and now I am a little lost. Is there an easier way to do this? Do I have to rearrange my data or can this be changed around using the original xyplot command line. Thanks.

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 01 Jul 2008 - 22:22:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Jul 2008 - 23:31:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive