问题描述
我正在尝试更改R包中一些命令的功能.很容易看到命令的来源.但是,该函数将调用程序包名称空间中的其他函数.这些函数不是导出的对象.那么我该如何访问它们?
I'm trying to alter the functionality of a few commands in a package in R. It's easy enough to see the source of the commands. However the function calls other functions that are in the package namespace. These functions are not exported objects. So how can I access them?
具体示例:
我将如何访问copula :: rmvdc中使用的asCall()函数?
How would I access the asCall() function that is used in copula::rmvdc?
require(copula)
copula::rmvdc
getAnywhere("asCall")
因此as.Call()
存在于copula程序包中,但是如何访问它?
so as.Call()
exists in the copula package, but how do I access it?
> copula::asCall
Error: 'asCall' is not an exported object from 'namespace:copula'
推荐答案
尝试一下:
copula:::asCall
这是以前在R-help上得到的答案一个>.该函数未在程序包名称空间中导出,因此您需要使用:::
运算符.通常,在不打算将其用于一般用途时(例如,在这种情况下您无需对其进行记录),不会将其导出.
This was previously answered on R-help. That function was not exported in the package namespace, so you need to use the :::
operator instead. Typically functions are not exported when they are not intended for general usage (e.g. you don't need to document them in this case).
这篇关于从名称空间调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!