在R中,是否有可能抑制;注意:全局变量“的绑定不可见”;?
我想知道是否有可能在R中抑制这些干扰控制台的输出:在R中,是否有可能抑制;注意:全局变量“的绑定不可见”;?,r,reference-class,R,Reference Class,我想知道是否有可能在R中抑制这些干扰控制台的输出: Note: no visible binding for global variable '.->ConfigString' Note: no visible binding for '<<-' assignment to 'ConfigString' 注意:全局变量'.->ConfigString'没有可见绑定 注:“无可见绑定,此答案全部归功于@Tyler Rinker 要消除这些注释,请在上面的源代码前面加上以下前
Note: no visible binding for global variable '.->ConfigString'
Note: no visible binding for '<<-' assignment to 'ConfigString'
注意:全局变量'.->ConfigString'没有可见绑定
注:“无可见绑定,此答案全部归功于@Tyler Rinker
要消除这些注释,请在上面的源代码前面加上以下前缀:
# Intent:
# This function suppresses the following notes generated by "R CMD check":
# - "Note: no visible binding for global variable '.->ConfigString'"
# - "Note: no visible binding for '<<-' assignment to 'ConfigString'"
# Usage:
# Add the following right in the beginning of the .r file (before the Reference
# class is defined in the sourced .r file):
# suppressBindingNotes(c(".->ConfigString","ConfigString"))
suppressBindingNotes <- function(variablesMentionedInNotes) {
for(variable in variablesMentionedInNotes) {
assign(variable,NULL, envir = .GlobalEnv)
}
}
suppressBindingNotes(c(".->ConfigString","ConfigString"))
#意图:
#此函数用于抑制“R CMD check”生成的以下注释:
#-“注意:全局变量'.->ConfigString'没有可见绑定”
#-“注意:'没有可见的绑定。您可以尝试此命令
编译器::设置编译器选项(suppressAll=TRUE)
这对我来说可以抑制以下消息
注意:全局变量没有可见的绑定…
注意:全局函数定义没有可见的绑定
你看到了吗?如果你读了我链接的内容,你就不会把这些称为“可怕的、无关的错误”。也许是可怕的。当然是无关的。错误?甚至不接近。@joran你是对的,我把“错误”改成了“注意”“。添加类似于ConfigString@Tyler Rinker的内容您是对的,这解决了问题。我在下面添加了一个答案,我希望这里能给你的答案投10票!这是否比使用utils::globalVariables
更“可怕”?
# Intent:
# This function suppresses the following notes generated by "R CMD check":
# - "Note: no visible binding for global variable '.->ConfigString'"
# - "Note: no visible binding for '<<-' assignment to 'ConfigString'"
# Usage:
# Add the following right in the beginning of the .r file (before the Reference
# class is defined in the sourced .r file):
# suppressBindingNotes(c(".->ConfigString","ConfigString"))
suppressBindingNotes <- function(variablesMentionedInNotes) {
for(variable in variablesMentionedInNotes) {
assign(variable,NULL, envir = .GlobalEnv)
}
}
suppressBindingNotes(c(".->ConfigString","ConfigString"))