Hi,

   How could I see the source code of functions in an R package?
   If we type ?function_name , we will see documentations of the
function_name.
   If we type function_name, is what returns just the source code? Could we
just save it in an .R file and modify as we want? However, it seems that
sometimes the source code is hidden (or stored elsewhere?) As an example,
could we see the source code of "xyplot" in the following example?

   Thanks,


> library(lattice)
> xyplot
function (x, data, ...)
UseMethod("xyplot")
<environment: namespace:lattice>

> library(plm)
Loading required package: bdsmatrix

Attaching package: ‘bdsmatrix’

The following object(s) are masked from ‘package:base’:

    backsolve

Loading required package: nlme
Loading required package: Formula
Loading required package: MASS
Loading required package: sandwich
Loading required package: zoo

Attaching package: ‘zoo’

The following object(s) are masked from ‘package:base’:

    as.Date, as.Date.numeric

> ?plm
> plm
function (formula, data, subset, na.action, effect = c("individual",
    "time", "twoways"), model = c("within", "random", "ht", "between",
    "pooling", "fd"), random.method = c("swar", "walhus", "amemiya",
    "nerlove", "kinla"), inst.method = c("bvk", "baltagi"), index = NULL,
    ...)
{
    nframe <- length(sys.calls())
    is.a.list <- class(formula)[1] == "list"
    if (is.a.list) {
        plmlist <- match.call(expand.dots = FALSE)
        plmlist[[1]] <- as.name("plm.list")
        plmlist <- eval(plmlist, sys.frame(which = nframe))
        return(plmlist)
    }
    dots <- list(...)
    effect <- match.arg(effect)
    if (!any(is.na(model)))
        model <- match.arg(model)
    random.method <- match.arg(random.method)
    inst.method <- match.arg(inst.method)
    if (!is.na(model) && model == "ht") {
        ht <- match.call(expand.dots = FALSE)
        m <- match(c("formula", "data", "subset", "na.action",
            "index"), names(ht), 0)
        ht <- ht[c(1, m)]
        ht[[1]] <- as.name("pht")
        ht <- eval(ht, parent.frame())
        return(ht)
    }
    if (!is.null(dots$instruments)) {
        as.Formula(formula, dots$instruments)
        deprec.instruments <- paste("the use of the instruments argument is
deprecated,",
            "use two-part formulas instead")
        warning(deprec.instruments)
    }
    if (inherits(data, "pdata.frame") && !is.null(index))
        warning("the index argument is ignored because data is a
pdata.frame")
    if (!inherits(data, "pdata.frame"))
        data <- pdata.frame(data, index)
    if (!inherits(formula, "pFormula"))
        formula <- pFormula(formula)
    if (length(formula)[2] == 2)
        formula <- expand.formula(formula)
    cl <- match.call()
    mf <- match.call(expand.dots = FALSE)
    m <- match(c("formula", "data", "subset", "na.action"), names(mf),
        0)
    mf <- mf[c(1, m)]
    mf$drop.unused.levels <- TRUE
    mf[[1]] <- as.name("model.frame")
    mf$formula <- formula
    mf$data <- data
    data <- eval(mf, parent.frame())
    if (is.na(model)) {
        attr(data, "formula") <- formula
        return(data)
    }
    args <- list(model = model, effect = effect, random.method =
random.method,
        inst.method = inst.method)
    result <- plm.fit(formula, data, model, effect, random.method,
        inst.method)
    result$call <- cl
    result$args <- args
    result
}
<environment: namespace:plm>

	[[alternative HTML version deleted]]

