Skip to content
Prev 156417 / 398506 Next

Plotting curves in lattice panels

On 9/18/08, David Scott <d.scott at auckland.ac.nz> wrote:
Something like this should work:

xyplot(ferritin  ~ total|gender, data = blood,
       panel = function(x, y, ...){
           panel.xyplot(x, y)
           fm <- lm(log(y) ~ x)
           panel.curve(exp(predict(fm, newdata = list(x = x))))
       })

-Deepayan