[R] sorting in lmList object

Douglas Bates bates at stat.wisc.edu
Thu Feb 13 17:09:53 CET 2003


emb7 at st-andrews.ac.uk writes:

> Hi all,
> Forgive me if this is an obvious one....
> I want to make a plot of confidence intervals from an lmList object with a 
> collection of simple linear models (lm(y~x)) using:
> 
> plot(intervals(mylmList))
> 
> and sort the plot by increasing mean values for the intercept. Is there an easy 
> way of doing this? I've tried the "order()" and "sort.list()" functions, but I 
> suspect they only work for data frames? Can I sort directly when plotting, or 
> do I have to sort the whole lmList object?

I think the easiest way to do this would be to ensure that the
grouping factor that you pass to lmList is an ordered factor with the
desired ordering.  This may involve two passes through lmList - the
first to get the ordering and the second to create an lmList object
with the desired ordering.




More information about the R-help mailing list