SCM

SCM Repository

[latticeextra] Annotation of /pkg/R/panel.2dsmoother.R
ViewVC logotype

Annotation of /pkg/R/panel.2dsmoother.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 81 - (view) (download)

1 : felix 71
2 :     panel.2dsmoother <-
3 :     function(x, y, z, subscripts = TRUE,
4 :     form = z ~ x * y, method = "loess", ...,
5 : felix 81 args = list(), n = 100)
6 : felix 71 {
7 :     if (length(subscripts) == 0)
8 :     return()
9 :     ## allow 'form' to be passed as the first argument
10 :     missing.x <- missing(x)
11 :     if (!missing.x && inherits(x, "formula")) {
12 :     form <- x
13 :     missing.x <- TRUE
14 :     }
15 :     ## use 'x', 'y', 'z' if given
16 :     ## otherwise try to find them in the formula environment
17 :     if (missing.x)
18 :     x <- environment(form)$x
19 :     if (missing(y))
20 :     y <- environment(form)$y
21 :     if (missing(z))
22 :     z <- environment(form)$z
23 :     x <- x[subscripts]
24 :     y <- y[subscripts]
25 :     z <- z[subscripts]
26 :     data <- list(x = x, y = y, z = z)
27 :     mod <- do.call(method,
28 :     c(alist(form, data = data), args))
29 :     ## use the limits of the data, or panel limits, whichever is smaller
30 :     lims <- current.panel.limits()
31 :     xrange <- c(max(min(lims$x), min(x)), min(max(lims$x), max(x)))
32 :     yrange <- c(max(min(lims$y), min(y)), min(max(lims$y), max(y)))
33 :     xseq <- seq(xrange[1], xrange[2], length = n)
34 :     yseq <- seq(yrange[1], yrange[2], length = n)
35 :     zseq <- seq(min(z), max(z), length = n)
36 :     grid <- expand.grid(x = xseq, y = yseq)
37 :     fit <- predict(mod, grid)
38 :     panel.levelplot(x = grid$x, y = grid$y, z = fit, subscripts = TRUE,
39 :     ...)
40 :     }

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge