[R] order of panels in xyplots

S Devriese sdmaillist at gmail.com
Wed Nov 25 19:50:15 CET 2009


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




More information about the R-help mailing list