Hi, I am having an issue with a custom panel for lattice. The problem comes when I try passing a groups argument.
Here is the custom panel, a wrapper for smooth spline. I copied panel.loess and replaced the loess arguments with smooth.spline(). [Note: I would like to use the cross-validation fitting properties of smooth.spline.] library(lattice) panel.smooth.spline<-function(x,y,w=NULL, df, spar = NULL, cv = FALSE, lwd=plot.line$lwd, lty=plot.line$lty,col, col.line=plot.line$col, type, horizontal=FALSE,... ){ x <- as.numeric(x) y <- as.numeric(y) ok <- is.finite(x) & is.finite(y) if (sum(ok) < 1) return() if (!missing(col)) { if (missing(col.line)) col.line <- col } plot.line <- trellis.par.get("plot.line") if (horizontal) { spline <- smooth.spline(y[ok], x[ok], ...) panel.lines(x = spline$y, y = spline$x, col = col.line, lty = lty, lwd = lwd, ...) } else { spline <- smooth.spline(x[ok], y[ok],...) panel.lines(x = spline$x, y = spline$y, col = col.line, lty = lty, lwd = lwd, ...) } } # Here is my test data frame set.seed(25) test<-data.frame(x=c(1:200), y=rnorm(200), groups=gl(4,200/4)) # This call to xyplot works, but the smoother colors are not unique. xyplot(y~x|groups, data=test, panel=function(...){ panel.xyplot(...) panel.smooth.spline(...) }) # This call to xyplot doesn't work and results in an error "error using packet" xyplot(y~x|groups, data=test, groups=groups, panel=function(...){ panel.xyplot(...) panel.smooth.spline(...) }) I think this should be quite simple but I must be too simple minded. Thanks for any help. Jon Loehrke Graduate Research Assistant Department of Fisheries Oceanography School for Marine Science and Technology University of Massachusetts 200 Mill Road, Suite 325 Fairhaven, MA 02719 [EMAIL PROTECTED] sessionInfo() R version 2.8.0 Patched (2008-11-24 r47017) i386-apple-darwin9.5.0 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-17 zoo_1.5-4 loaded via a namespace (and not attached): [1] grid_2.8.0 tools_2.8.0 [[alternative HTML version deleted]] ______________________________________________ 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.