[R] plotting order of lines in xyplot panels while using conditioning variable and groups

RICHARD PITMAN richard.pitman3 at btopenworld.com
Wed Jun 20 11:40:07 CEST 2007


--- Deepayan Sarkar <deepayan.sarkar at gmail.com> wrote:

> On 6/19/07, RICHARD PITMAN
> <richard.pitman3 at btopenworld.com> wrote:
<snip>
> > I have tried reordering
> the
> > levels in data$group:
> >
> > data$group<-factor(data$group,
> > levels=c("CV_model_event_1","CV model event 2","CV
> > event
> >
> 1","CV_event_2","CV_event_2_CVA","CV_event_2_TIA"))
> >
> > but this changed nothing.
> >
> > Any suggestions gratefully received.
> 
> It's hard to see the problem without a reproducible
> example, but if
> all you want is to order the levels of groups in
> decreasing order of
> frequency, you could use
> 
>  groups  = reorder(group, group, function(x) {
> -length(x) }),
> 
> -Deepayan
> 

Thanks Deepayan, that's a useful trick to know. I am
rather embarrassed, the problem was one of basic R
usage/syntax. When reordering the levels I just needed
to replace data$group with group (i.e. omitting data$
from the command) and all was well. I shall go and sit
in the dog-house and do penance :(

Thanks for your time.

Regards

Richard



More information about the R-help mailing list