Dear R-users I have 5 dependent variables (y1 to y5) and one independent variable (x) and 3 conditioning variables (m, n, and 0). Each of the conditioning variables has 2 levels. I created 2*4 panel plots. xyplot(y1+y2+y3+y4+y5 ~ x | m*n*o,layout = c(4,2)) I would like to reorder the 8 panels. I tried to use index.cond (e.g., index.cond = list(c(1,3,2,4,5,7,6,8)) but it didn't work out. I got a error message "Error in cond.orders(foo) : Invalid value of index.cond". Please let me know if I didn't use index.cond argument properly. I looked at the example in R-help but all examples have just only one conditioning variable. Is there any way I can arrange the panels in whatever order I want ? Thanks Taka
That's not a valid specification. See the description of the index.cond argument in ?xyplot and in particular this part: If 'index.cond' is a list, it has to be as long as the number of conditioning variables, and the 'i'-th component has to be a valid indexing vector for the integer vector '1:nlevels(g_i)' (which can, among other things, repeat some of the levels or drop some altogether). Thus in your case index.cond is a list with three components and each of those components can specify a vector of the levels of interest in the order of interest. For example, compare the output of these two to get the idea where CO2 is a builtin data set: xyplot(conc ~ uptake | Type * Treatment, CO2, index.cond = list(1:2, 1:2)) xyplot(conc ~ uptake | Type * Treatment, CO2, index.cond = list(1:2, 2:1)) On 8/9/06, Taka Matzmoto <sell_mirage_ne at hotmail.com> wrote:> Dear R-users > > I have 5 dependent variables (y1 to y5) and one independent variable (x) and > 3 conditioning variables (m, n, and 0). Each of the conditioning variables > has 2 levels. I created 2*4 panel plots. > > xyplot(y1+y2+y3+y4+y5 ~ x | m*n*o,layout = c(4,2)) > > I would like to reorder the 8 panels. I tried to use index.cond (e.g., > index.cond = list(c(1,3,2,4,5,7,6,8)) but it didn't work out. I got a error > message "Error in cond.orders(foo) : Invalid value of index.cond". Please > let me know if I didn't use index.cond argument properly. > > I looked at the example in R-help but all examples have just only one > conditioning variable. > > Is there any way I can arrange the panels in whatever order I want ? > > Thanks > > Taka > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
On 8/9/06, Taka Matzmoto <sell_mirage_ne at hotmail.com> wrote:> Dear R-users > > I have 5 dependent variables (y1 to y5) and one independent variable (x) and > 3 conditioning variables (m, n, and 0). Each of the conditioning variables > has 2 levels. I created 2*4 panel plots. > > xyplot(y1+y2+y3+y4+y5 ~ x | m*n*o,layout = c(4,2)) > > I would like to reorder the 8 panels. I tried to use index.cond (e.g., > index.cond = list(c(1,3,2,4,5,7,6,8)) but it didn't work out. I got a error > message "Error in cond.orders(foo) : Invalid value of index.cond". Please > let me know if I didn't use index.cond argument properly.Gabor has already explained why this is wrong.> I looked at the example in R-help but all examples have just only one > conditioning variable. > > Is there any way I can arrange the panels in whatever order I want ?Think of a lattice plot as a an array, with each conditioning variable defining a dimension. In your case, it's a 3-dimensional array. If you assign the result of the xyplot call to a variable, you can reorder the indices just like an array, e.g.: p <- xyplot(y1+y2+y3+y4+y5 ~ x | m*n*o,layout = c(4,2)) p[, 2:1, 1] (this is just a convenient way of specifying index.cond). You cannot arrange the panels ``any way you want'', you can only rearrange columns/rows/whatever. If you really do want an arbitrary arrangement, then you don't want 3 different conditioning variables, you want only one. If you want a separate panel for each combination of m, n and o, create a new factor as their interaction, e.g. p <- xyplot(y1+y2+y3+y4+y5 ~ x | m:n:o,layout = c(4,2)) Then, you have a one-dimensional vector-like object, which you can reorder by p[c(1,3,2,4,5,7,6,8)] etc. -Deepayan