All -- is there a way to put the correlation figures inside the xyplot charts? I can do it using plot, e.g.
with(iris, plot(Sepal.Length, Petal.Length, pch=16), cex=1, main="Length: Sepal vs. Petal")
abline(fit <- lm(Sepal.Length ~ Petal.Length, data=iris), col='red')
legend("topleft", bty="n", legend=paste("R2 =", format(summary(fit)$adj.r.squared, digits=4)))
However, this doesn't work when I use the lattice chart through xyplot, e.g.
xyplot(Sepal.Length ~ Petal.Length | Species, data = iris,
main = "Length: Sepal vs. Petal, by Species",
col = "darkblue", cex = 0.8, type=c("p","r"))
As the regression line for each panel is not named or accessible (unlike 'fit' in the previous example). Although the R2 can be calculated individually, putting all of the information in each panel in the chart seems like a graceful solution. I would appreciate your advice or even a better way to show the same information. Thank you.