I have loaded the lattice package. Then I run:
> xyplot(yyy ~ xxx | zzz, panel = function(x,y) { panel.lmline(x,y)}
This produces panels of plot, showing the regression line, without the xyplots.
I am doing the panel.lmline without fully understanding how it is done. I know there is a data argument, what is the data, knowing that I have the 3 variables xxx
, yyy
, zzz
?
All you really need is:
where the
type
argument is documented in?panel.xyplot
I won't quote it all but
You can, as I showed above, add these in series by passing
type
a character vector. Essentially, your code gave the same result astype = "r"
, i.e. only the regression line was drawn.The
panel
argument ofxyplot
, and Lattice plotting functions in general, is extremely powerful but not always required to so quite complex things. Basically you need to passpanel
a function which will draw things on each panel of the plot. To modify your code to do what you wanted, we need to add a call topanel.xyplot()
as well. E.g.:It is also very useful to pass all other arguments on the individual panel functions via
...
, in which case you need...
as an argument in your anonymous functions (as shown above). In fact, you can probably write that panel function part as:but I usually add the
x
andy
arguments just to be clear.