I'd like do a simple xyplot with customized order of panels and try to understand how to use index.cond for that. Several attempts didn't deliver the correct results. Now, I noticed the following:> p <- xyplot(dur~roi|trial, data) > p$index.cond[[1]] [1] 1 2 3 4 5 6 7 8 9 10 These numbers are "valid indexing vector for the integer vector '1:nlevels(g_i)'" but levels(data$trial)[p$index.cond[[1]]] does not yield the correct level names of the data points in data. (Actually the first ten levels are not used in data.) I was expecting that this should plot the panels in the order in which the levels occur in the data frame: xyplot(dur~roi|trial, data, index.cond=unique(as.integer(data$trial))) But this leaves the panels empty. Could anybody please help me to understand this? Thanks! Titus
On Wed, Nov 25, 2009 at 7:03 PM, Titus Malsburg <malsburg at gmail.com> wrote:> ?I was expecting > that this should plot the panels in the order in which the levels > occur in the data frame: > > ?xyplot(dur~roi|trial, data, index.cond=unique(as.integer(data$trial)))The answer is apparently: xyplot(dur~roi|trial, data, index.cond=rank(unique(data$trial))) (Strange phenomenon, that I very often find the solution myself minutes after posting to the mailing list.) Best, Titus
On 11/25/2009 07:33 PM, Titus Malsburg wrote:> On Wed, Nov 25, 2009 at 7:03 PM, Titus Malsburg <malsburg at gmail.com> wrote: > >> I was expecting >> that this should plot the panels in the order in which the levels >> occur in the data frame: >> >> xyplot(dur~roi|trial, data, index.cond=unique(as.integer(data$trial))) >> > The answer is apparently: > > xyplot(dur~roi|trial, data, index.cond=rank(unique(data$trial))) > > (Strange phenomenon, that I very often find the solution myself > minutes after posting to the mailing list.) > > Best, > Titus > > ______________________________________________ > 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. >An alternative could be to reorder the levels of "trial" prior to calling xyplot or in the xyplot call itself (useful if you want to order the levels on some other criterion like the mean or median of another variable). See ?reorder Just a thought S