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

From: RICHARD PITMAN <richard.pitman3_at_btopenworld.com>
Date: Wed, 20 Jun 2007 10:40:07 +0100 (BST)

> 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



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. Received on Wed 20 Jun 2007 - 09:47:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Jun 2007 - 10:32:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.