CRAN 提交失败 - 警告:未找到与“show”方法导出相对应的函数

问题描述 投票:0回答:1

我最近向CRAN提交了我的Rpackage,在检查过程中遇到了一个NOTE。注意看起来像这样:

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))
})

在命名空间中有一行看起来像这样:

exportMethods(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 上我从未经历过这个注释。

r cran
1个回答
0
投票

我通过在

setMethod("show"

前面添加以下代码块来解决此警告消息
#' Show
#' @importFrom methods show
#' @inheritParams methods::show
#' @export
show <- methods::show

methods
添加到
Imports:
文件中的
DESCRIPTION
部分

© www.soinside.com 2019 - 2024. All rights reserved.