基于此 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, pkgname) {
ns <- asNamespace(pkgname)
makeActiveBinding("my_active_binding", my_function, env = ns)
namespaceExport(ns, "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 检查?