Dear community,

I am looking for a possibility to draw 'regression lines' instead of 'smooth' lines in grouped xyplots. The following code should give you a small example of the data structure.


library(lattice)
data(Gcsemv, package = "mlmRev")

# Creates artificial grouping variable ...
Gcsemv$Groups <-
  ifelse(as.numeric(as.character(Gcsemv$school))>65000,
         "Group1", "Group2")

xyplot(written ~ course | gender, data = Gcsemv,
       type = c("g", "p", "smooth"),
       groups = Groups,
       panel = function(x, y, ...) {
         panel.xyplot(x, y, ...)
# Here I want to draw the regression lines
#         panel.abline(x, y)
       },
       auto.key = list(space = 'right'))


I tried some variations like 'lm(y~x)' inside panel.abline() but had no success. Also googling around and reading in Deepayan Sakars interesting new book gave me no hints.

Is there any chance of displaying regression lines (instead of smooth function) within grouped panels? Or am I entirely wrong with this?

Thanks in advance,
Rainer Hurling



> sessionInfo()
R version 2.7.1 Patched (2008-08-01 r46207)
i386-unknown-freebsd8.0

locale:
de_DE.ISO8859-15/de_DE.ISO8859-15/C/C/de_DE.ISO8859-15/de_DE.ISO8859-15

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] cclust_0.6-14   lattice_0.17-13 chron_2.3-24

loaded via a namespace (and not attached):
[1] grid_2.7.1  tools_2.7.1

______________________________________________
R-help@r-project.org mailing list
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