[R] Multipanel weighted regression lines.
Damon Wischik
djw1005 at cam.ac.uk
Tue Jul 15 02:06:33 CEST 2003
Kevin Brown asks:
> Does someone know where there are some beginners examples on how to
> create and use panel.xxx functions in conjunction with the xyplot
> functions?
I don't know of any formal resources other than the help page. I worked
out about panel functions by experimenting with functions of the form
panel=function(...) print(...)
!
> The second way would be to fiddle around with the function below to add
> the "weights" to the lm function call. I do not know how to change this
> "plot.regression" function to do that.
I would use the subscripts=TRUE argument to xyplot. Then your panel
function will receive an argument named subscripts, which indicates which
rows of your data are being plotted in this panel. For example, something
like
xyplot ( yg~xg | g, subscripts=TRUE, panel=function(x,y,subscripts,...) {
panel.xyplot(x,y)
thisPanel <- unique(g[subscripts])
fit <- lm(y~x and something involving thisPanel)
panel.abline(fit)
})
Damon Wischik.
More information about the R-help
mailing list