使用insertSource在系统范围内修改R函数

使用insertSource在系统范围内修改R函数,r,R,我想根据作者的建议修改“ape”包的“ace”功能。我将修改后的函数写入了“ace2.r”,并希望用我的函数替换包中的标准“ace”函数(参见此处:): insertSource(“ace2.r”,package=“ape”,functions=“ace”) 但我明白了 警告消息: 在insertSource(“ace2.r”,package=“ape”,functions=“ace”):无法插入这些(在源代码中找不到):“ace” 我检查了?insertSource,但我没有得到“函数”应该给

我想根据作者的建议修改“ape”包的“ace”功能。我将修改后的函数写入了“ace2.r”,并希望用我的函数替换包中的标准“ace”函数(参见此处:):

insertSource(“ace2.r”,package=“ape”,functions=“ace”)

但我明白了

警告消息:
在insertSource(“ace2.r”,package=“ape”,functions=“ace”):无法插入这些(在源代码中找不到):“ace”


我检查了?insertSource,但我没有得到“函数”应该给出的内容修改函数有点复杂和危险,您可以使用新名称创建修改后的版本。假设函数是substr

在控制台中写入substr,然后按enter键,返回

> substr
function (x, start, stop) 
{
if (!is.character(x)) 
x <- as.character(x)
.Internal(substr(x, as.integer(start), as.integer(stop)))
}
<bytecode: 0x000000000d7d4ec0>
<environment: namespace:base>
>substr
功能(x、启动、停止)
{
如果(!是.字符(x))

您好,Jibbah。请阅读并更新您的问题。如目前所述,它太模糊,无法有效回答。作为背景,您为什么要这样做?我猜这可能会损害您工作的可复制性。如果您想使用自定义函数,为什么不使用
源(“path/to/your/function.R”)加载它
在一个新脚本开始时?可能相关:因此我重新制定了我的问题。我遵循亚当·斯密和塞尔库克·阿克巴斯的建议,将修改后的函数存储到一个新脚本中。但是我仍然想知道如何将这些更改实现到包的函数中
my_substr <- function (x, start, stop) 
{
if (!is.character(x)) 
x <- as.character(x)
.Internal(substr(x, as.integer(start), as.integer(stop)+1))
}