我最近向CRAN提交了我的R package,在检查过程中我遇到了一个注解。注解看起来像这样:
Check: whether the namespace can be loaded with stated dependencies, Result: NOTE
Warning: no function found corresponding to methods exports from 'hmsr' for: 'show'
A namespace must be able to be loaded with just the base namespace
loaded: otherwise if the namespace gets loaded by a saved object, the
session will be unable to start.
Probably some imports need to be declared in the NAMESPACE file.
字符串
我正在寻求帮助来理解和解决这个问题。show
是这样定义的:
#' Show method for class "hms".
#'
#' @param object - hms s4 object
#'
#' @return It returns the names of the slots and the classes associated with the
#' slots in the "hms" class. It prints call details.
#'
#' @export
#'
#' @examples
#' f <- function(x) x
#' result <- hms(fitness = f, lower = -5, upper = 5)
#' show(result)
setMethod("show", "hms", function(object) {
cat("An object of class \"hms\"\n")
cat("\nCall:\n", deparse(object@call), "\n\n", sep = "")
cat("Available slots:\n")
print(methods::slotNames(object))
})
型
在NAMESPACE中,有一行看起来像这样:
exportMethods(show)
型
我正在调查show是否定义正确,GA包是否有一个非常类似的show
方法:
setMethod("show", "ga",
function(object)
{ cat("An object of class \"ga\"\n")
cat("\nCall:\n", deparse(object@call), "\n\n",sep="")
cat("Available slots:\n")
print(slotNames(object))
})
型
我不能在我的个人电脑上用Windows复制这张纸条。在Mac OS上我从来没有经历过这张纸条。
1条答案
按热度按时间6vl6ewon1#
我通过在
setMethod("show"
前面添加以下代码块来摆脱此警告消息字符串
将
methods
添加到DESCRIPTION
文件的Imports:
部分