[R] lattice: reverse order of panel.lmline, panel.smooth

Deepayan Sarkar deepayan.sarkar at gmail.com
Sat Jan 24 01:45:51 CET 2009


On Fri, Jan 23, 2009 at 3:00 PM, Dylan Beaudette
<debeaudette at ucdavis.edu> wrote:
> Hi,
>
> is it possible to reverse the order in which panel.lmline() or panel.smooth()
> operation in xyplot() ? This type of situation might occur when plotting some
> variable with depth, but the relation we want to describe is variable ~
> depth, and not depth ~ variable, as the plotting formula would suggest.
>
>
> # an example:
> d <- 1:100
> v <- d * rnorm(100)
> xyplot(d ~ v, ylim=c(100,0), type=c('p','r','smooth'))
>
> # points are positioned correctly, but the lmline and smoothed line are in
> opposite the "desired" orientation. obviously xyplot() has no way of knowing
> this, but can it be convinced?

type="g", "smooth", "r", etc. are all convenience shortcuts for other
panel functions (panel.grid, panel.loess, panel.lmline, respectively).
Whenever you find its use limiting, you should consider writing an
explicit panel function.

In this case, simply adding 'horizontal=TRUE' will suffice for the
smooth (it gets passed on to panel.loess), but not for panel.lmline
(maybe I should add it 'horizontal' as an argument to it too).

-Deepayan




More information about the R-help mailing list