如何解决默认情况下,当活动绑定失败时,在包中定义活动绑定
Based on this Q&A,此代码定义了一个包含对值1进行有效绑定的包。它传递devtools::check()
:
my_function <- function() 1
#' return 1
#' @usage my_active_binding
#' @name my_active_binding
NULL
.onLoad <- function(libname,pkgname) {
ns <- asNamespace(pkgname)
makeActiveBinding("my_active_binding",my_function,env = ns)
namespaceExport(ns,"my_active_binding")
}
但是,如果默认情况下我的活动绑定失败(在我的用例中,它应在特定的上下文中使用),
则devtools::check()
不再快乐。
编辑:实际上,如果我使用print()
或message()
而不是stop()
,则会遇到相同的问题
my_function <- function() stop("stop!!!")
#' stop!!!
#' @usage my_active_binding
#' @name my_active_binding
NULL
.onLoad <- function(libname,"my_active_binding")
}
请参见下文:
-- R CMD check results ---------------------------------- abtest 0.0.0.9000 ----
Duration: 21s
> checking DESCRIPTION meta-information ... WARNING
Non-standard license specification:
GPL3
Standardizable: FALSE
> checking S3 generic/method consistency ... WARNING
Error in (function () : stop!!!
Calls: <Anonymous> -> Filter -> unlist -> lapply -> FUN -> <Anonymous>
Ex�cution arr�t�e
See section 'Generic functions and methods' in the 'Writing R
Extensions' manual.
> checking for code/documentation mismatches ... WARNING
Error in (function () : stop!!!
Calls: <Anonymous> ... Filter -> unlist -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
> checking dependencies in R code ... NOTE
Error in (function () : stop!!!
Ex�cution arr�t�e
> checking foreign function calls ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
See chapter 'System and foreign language interfaces' in the 'Writing R
Extensions' manual.
> checking R code for possible problems ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> ... withCallingHandlers -> do.call -> <Anonymous> -> get -> <Anonymous>
Ex�cution arr�t�e
> checking Rd \usage sections ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> ... Filter -> unlist -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
The \usage entries for S3 methods should use the \method markup and not
their full name.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
0 errors v | 3 warnings x | 4 notes x
Erreur : R CMD check found WARNINGs
Ex�cution arr�t�e
Exited with status 1.
我该怎么做才能将此活动绑定集成到我的软件包中并满足devtools::check()
/ R CMD检查?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。