相关疑难解决方法(0)

什么时候包需要使用:::作为自己的对象

考虑这个R包有两个函数,一个是导出的,另一个是内部的

hello.R

#' @export
hello <- function() {
  internalFunctions:::hello_internal()
}
Run Code Online (Sandbox Code Playgroud)

hello_internal.R

hello_internal <- function(x){
    print("hello world")
}
Run Code Online (Sandbox Code Playgroud)

NAMESPACE

# Generated by roxygen2 (4.1.1): do not edit by hand

export(hello)
Run Code Online (Sandbox Code Playgroud)

当检查(devtools::check())时,它返回NOTE

There are ::: calls to the package's namespace in its code. A package
  almost never needs to use ::: for its own objects:
  ‘hello_internal’
Run Code Online (Sandbox Code Playgroud)

鉴于NOTE几乎没有,在什么情况下一个包需要使用:::其自己的对象?


额外

我有一个非常相似的相关问题,我确实需要:::内部函数,但我不知道为什么需要它.希望有一个答案可以解决这个问题.我怀疑解锁环境正在做一些我不期望的事情,因此不得不使用:::内部功能.

如果他们被认为是彼此的重复,我将删除另一个.

r r-package

12
推荐指数
1
解决办法
372
查看次数

标签 统计

r ×1

r-package ×1