Re: [R] getting panel.loess to use updated version of loess.smooth

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Wed 13 Jul 2005 - 04:44:21 EST

Benjamin Tyner wrote:
> I'm updating the loess routines to allow for, among other things,
> arbitrary local polynomial degree and number of predictors. For now,
> I've given the updated package its own namespace. The trouble is,
> panel.loess still calls the original code in package:stats instead of
> the new loess package, regardless of whether package:loess or
> package:lattice comes first in the search list. If I export panel.loess
> from the new package, then it can't see grid.lines anymore.
>
> I've tried using fixInNamespace to change the loess.smooth in
> package:stats to point to the updated simpleLoess, but it is locked. At
> http://tolstoy.newcastle.edu.au/R/help/04/05/0428.html it was suggested
> to write a new panel function. However I still need to be able to access
> grid.lines, and getFromNamespace("grid.lines","grid") is not the way to
> do this.
>
> Any ideas? This seems simple but I'm stumped.
>
> Thanks,
> Ben
>

Can you show us what you tried? It seems as simple as defining a new panel function:

panel.loess2 <- function (x, y, span = 2/3, degree = 1,

                           family = c("symmetric", "gaussian"),
                           evaluation = 50, lwd = add.line$lwd,
                           lty = add.line$lty, col,
                           col.line = add.line$col, ...) {
   x <- as.numeric(x)

   y <- as.numeric(y)
   if (length(x) > 0) {
       if (!missing(col)) {
           if (missing(col.line))
               col.line <- col
       }
       add.line <- trellis.par.get("add.line")
       #smooth <- loess.smooth(x, y, span = span, family = family,
       #                       degree = degree, evaluation = evaluation)
       smooth <- simpleLoess(x, y, span = span, family = family,
                             degree = degree, evaluation = evaluation)
       grid.lines(x = smooth$x, y = smooth$y, default.units = "native",
                  gp = gpar(col = col.line, lty = lty, lwd = lwd))
   }
}

--sundar



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 13 04:47:08 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:35 EST