[R] Lattice: Setting Conditioning Panel Order in Trellis Plots

Rich Shepard rshepard at appl-ecosys.com
Fri Dec 30 16:47:00 CET 2011


On Fri, 30 Dec 2011, Duncan Murdoch wrote:

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

Duncan,

   Apologies; I did not know what supporting information to provide.

   It's a factor in the data frame, but obviously not in the desired order.

> To get that, try something like this (simplified to fewer levels, because
> I'm lazy):
> # Set the levels in the desired order:
> x <- factor(x, levels=c("SC", "SC-1", "SC-2", "SC-100"))

   Here's an example of the command:

xyplot(TDS ~ SO4 | site, data = snow.cast, main = 'TDS in Snow Canyon
Creek', ylab = 'Concentration (mg/L)', xlab = 'Sulfate (mg/L)')

   If I correctly understand, I'd first assign the desired sequence to a
variable (x in your example above), the specify that variable as the
conditioning factor in the formula; e.g,,

xyplot(TDS ~ SO4 | x, data = snow.cast, main = 'TDS in Snow Canyon
Creek', ylab = 'Concentration (mg/L)', xlab = 'Sulfate (mg/L)')

   Thanks very much for the insight!

Happy New Year,

Rich



More information about the R-help mailing list