[R] order panels in xyplot by increasing slope
Henric Winell
nilsson.henric at gmail.com
Sat Jun 1 13:02:22 CEST 2013
Ethan,
Jim Lemon skrev 2013-05-24 00:09:
> On 05/24/2013 06:21 AM, Belair, Ethan D wrote:
>> example.plot = xyplot(ht ~ time|tree, data=data,
>> type = c("r", "g", "p"),
>> par.settings=simpleTheme(col="blue"),
>> main="abc",
>> )
>> example.plot
> > ...
If you read '?xyplot' carefully, you'll note that 'index.cond' is
allowed to be a function. So I'd just use
update(example.plot, index.cond = function(x, y) coef(lm(y ~ x))[2])
to get the panels ordered by slope.
HTH,
Henric
>
> Hi Ethan,
> This may be what you want:
>
> panel.slope<-function(panel) {
> return(diff(range(panel$y,na.rm=TRUE))/
> diff(range(panel$x,na.rm=TRUE)))
> }
> panel.order<-
> order(unlist(lapply(example.plot$panel.args,panel.slope)))
>
> Jim
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list