用assignInNamespace覆盖包函数

时间:2018-12-20 15:03:44

标签: r

我正在尝试覆盖grid软件包assignInNamespace中的一个函数,以允许我使用列表作为其参数。

来自

> vpList
function (...) 
{
    vps <- list(...)
    vpListFromList(vps)
}
<bytecode: 0x0000016dc0671a90>
<environment: namespace:grid>

收件人

vpList <- function (vps) 
{
  grid::vpListFromList(vps)
}

似乎可行:

> assignInNamespace("vpList",vpList,ns="grid")
> grid::vpList
function (vps) 
{
  grid::vpListFromList(vps)
}

但是当我尝试使用它时出现错误:

> n <- c(viewport(name= "a"), viewport(name ="b"), viewport(name = "c"), viewport(name = "d"))
> vpTree( viewport(layout=grid.layout(2,2), name = "body"), grid::vpList(n))
Error: 'vpListFromList' is not an exported object from 'namespace:grid'
Called from: getExportedValue(pkg, name)

有什么建议吗?

0 个答案:

没有答案