In a conditional xyplot, I would like to add some numerical results in every 
panel.  Consider below example.
df <- data.frame(x = rnorm(100), name = "A")
df <- within(df, {y <- x + 0.2 * rnorm(100)})
df2 <- data.frame(x = rnorm(100), y = rnorm(100), name = "B")
df <- rbind(df, df2)
rm(df2)


with(df, xyplot(y ~ x | name, data = df, 
  panel = function(x, y, ...){
        panel.xyplot(x, y)
        panel.lmline(x, y, col = "grey")
  },
  auto.key = list(corner = c(1,0), x = 0.9, y = 0.1, 
  text = substitute(expression(R^{2} == myval), 
  list(myval = summary(lm(y ~ x))$r.squared)))))
There are two problems with this plot.  First, there is only one key.  I want 
two different keys for the two panels.  
Second, R^2 is for all data.  For each panel, I want R^2 calculated using only 
the data plotted in that panel.  
Please help.
Thanks,Naresh                                     
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to