[R] How to control in order of groups in xyplot
Rainer Hurling
rhurlin at gwdg.de
Sun Oct 31 09:19:07 CET 2010
A working minimal example would have been better, see FAQ.
But I think you are looking for the following:
X2 <- factor(c("m=2", "m=5", "m=10"), levels=c("m=2", "m=5", "m=10"))
Here levels are ordered in your way. There might be other solutions for
this ordering problem.
Hope it helps,
Rainer
On 31.10.2010 06:55 (UTC+1), Jie Liu wrote:
> Hi guys,
>
> I used the following R code to generate one plot
>
> library(lattice)
> xyplot(Y~X1|as.factor(X2)*as.factor(X3), groups = as.factor(X4),
> data=mydata)
>
> Both X2 and X3 have three values. X4 has two values. I got 3x3 grids and in
> each grid there are two curves about y~x1 for the two X4 values. I am quite
> happy with the plot except that I need a different layout of the 3x3 layout.
> For example, X2={"m=2", "m=5", and "m=10"} and it plots with the order
> "m=10", "m=2", and "m=5". Is there any way I can control the order of the
> groups in the whole plot? Thanks a lot,
>
> --Jerry
More information about the R-help
mailing list