[R] Lattice: Setting Conditioning Panel Order in Trellis Plots
Duncan Murdoch
murdoch.duncan at gmail.com
Fri Dec 30 16:06:19 CET 2011
On 11-12-30 9:56 AM, Rich Shepard wrote:
> I've looked in Deepayan Sarkar's book without finding how to specify the
> order of conditioning panels in a trellis plot. Here's the issue I'm trying
> to resolve:
>
> Sampling locations along a stream channel are not sequentially numbered.
> For example, the panel order for one plot (lower left to upper right, 4
> panels per row): SC, SC-1, SC-100, SC-139, SC-140, SC-141, SC-145. SC-2,
> SC-3, and SC-50. This is normal collation order, while I need numeric order.
>
> Is there a way for me to specify the panel order so the display is SC,
> SC-1, SC-2, SC-3, SC-50, SC-100, SC-139, SC-140, SC-141, SC-145? If so,
> please teach me how to do this.
You don't describe the variable holding those labels. If it is a factor
with the levels in the desired order then it should display properly.
To get that, try something like this (simplified to fewer levels,
because I'm lazy):
# Make up some sample data:
x <- c("SC", "SC-1", "SC-100", "SC-2")
# Set the levels in the desired order:
x <- factor(x, levels=c("SC", "SC-1", "SC-2", "SC-100"))
Duncan Murdoch
More information about the R-help
mailing list