代码之家  ›  专栏  ›  技术社区  ›  Yang Yang

如何检查“的源代码”返回级别“在R包”极端?[复制]

r
  •  0
  • Yang Yang  · 技术社区  · 7 年前

    > t
    function (x) 
    UseMethod("t")
    <bytecode: 0x2332948>
    <environment: namespace:base>
    

    在这种情况下,怎么办 UseMethod("t") t(1:10) ?

    我看到的时候有区别吗 UseMethod 当我看到 standardGeneric 和 showMethods ,如 with ?

    > with
    standardGeneric for "with" defined from package "base"
    
    function (data, expr, ...) 
    standardGeneric("with")
    <bytecode: 0x102fb3fc0>
    <environment: 0x102fab988>
    Methods may be defined for arguments: data
    Use  showMethods("with")  for currently available ones.
    

    在其他情况下,我可以看到R函数正在被调用,但是我找不到这些函数的源代码。

    > ts.union
    function (..., dframe = FALSE) 
    .cbind.ts(list(...), .makeNamesTs(...), dframe = dframe, union = TRUE)
    <bytecode: 0x36fbf88>
    <environment: namespace:stats>
    > .cbindts
    Error: object '.cbindts' not found
    > .makeNamesTs
    Error: object '.makeNamesTs' not found
    

    我怎么找到像这样的函数 .cbindts 和 .makeNamesTs

    > matrix
    function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL) 
    {
        if (is.object(data) || !is.atomic(data)) 
            data <- as.vector(data)
        .Internal(matrix(data, nrow, ncol, byrow, dimnames, missing(nrow), 
            missing(ncol)))
    }
    <bytecode: 0x134bd10>
    <environment: namespace:base>
    > .Internal
    function (call)  .Primitive(".Internal")
    > .Primitive
    function (name)  .Primitive(".Primitive")
    

    .Primitive 功能是什么?类似地,有些函数调用 .C , .Call .Fortran .External ,或 .Internal . 我怎样才能找到它们的源代码?

    0 回复  |  直到 8 年前