2009-11-24 43 views

回答

18

只要輸入功能/方法的名稱不帶括號:

R> base::rev.default 
function (x) 
if (length(x)) x[length(x):1L] else x 
<environment: namespace:base> 

R-服務檯見 - 訪問來源R News Volume 6/4, October 2006

9

要找出你想看到哪些方法,寫methods(funcOfInterest)

有時不足以print(funcOfInterest.class)。然後嘗試print(getAnywhere(funcOfInterest.class))

+1

並注意,如果您正在交互式工作,則不需要顯式調用'print'。 – Dason 2012-11-02 20:00:30

15

您如何找到源代碼取決於函數的類型。請參閱my answer以解決此相關問題。

正如rcs指出的那樣,如果你想指定一個包,你可以使用::

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

並非包中的所有函數都將被導出(即公開提供);對於這些你需要使用:::

> lattice::xyplot.formula 
Error: 'xyplot.formula' is not an exported object from 'namespace:lattice' 

> lattice:::xyplot.formula 
function (x, data = NULL, allow.multiple = is.null(groups) || 
    outer, outer = !is.null(groups), auto.key = FALSE, aspect = "fill", 
    panel = lattice.getOption("panel.xyplot"), prepanel = NULL, 
    scales = list(), strip = TRUE, groups = NULL, xlab, xlim, 
    ylab, ylim, drop.unused.levels = lattice.getOption("drop.unused.levels"), 
    ..., lattice.options = NULL, default.scales = list(), subscripts = !is.null(groups), 
    subset = TRUE) 
{ 
    formula <- x 
    dots <- list(...) 
# etc.