[BioC] function within a function body?

SHEN, WEICHENG . WEICHENG.SHEN at saic.com
Fri May 16 10:48:38 MEST 2003


Hi all:

In studying the code for bioconductor, I found something that I don't
understand. The function implementation that I can not understand is
"maLowessLines." The function is listed below. The syntex that I don't
understand is "function(x, y, z)". It appears that this is a function within
a function (maLowessLines). What is the name of this function? Where does it
get the values of x, y, z? Any hints and suggestions will be greatly
appreciated. Thanks!

============================================================================
===================================


maLowessLines <- function (subset = TRUE, f = 0.3, col = 2, lty = 1, lwd =
2.5, 
    ...) 
{
    function(x, y, z) {
        subset <- maNum2Logic(length(x), subset)
        g <- unique(z[subset])
        if (length(col) < length(g)) 
            col <- rep(col[1], length(g))
        if (length(lty) < length(g)) 
            lty <- rep(lty[1], length(g))
        for (i in (1:length(g))) {
            which <- z[subset] == g[i]
            xx <- x[subset][which]
            yy <- y[subset][which]
            ind <- is.na(xx) | is.na(yy) | is.infinite(xx) | 
                is.infinite(yy)
            fit <- lowess(xx[!ind], yy[!ind], f = f)
            lines(fit, col = col[i], lty = lty[i], lwd = lwd, 
                ...)
        }
    }
}

Weicheng Shen, Ph.D.
Senior Image Analyst
Science Applications International Corporation
1710 SAIC Drive
Mail Stop 2-6-9
McLean, VA 22102
(703) 676-4189



More information about the Bioconductor mailing list