我有一个带有 S3 泛型和几种方法的包。我使用相同的函数来处理多个类,因此我将相同的函数分配给多个名称。我遇到的具体问题是 roxygen2 没有意识到这两个变量都绑定到 S3 方法,并且在不包含@S3method
指令的情况下,它无法导出某些 S3 方法。但是,这会导致弃用警告(“@S3method 已弃用。请改用@export”)
以下(人为的)小例子说明了这个问题:
#' The size of an object.
#' The size of an object
#'
#' @export
size <- function(x) UseMethod('size')
#' @export
size.default <- function(x) "I dunno"
#' @export
#' @S3method size matrix
size.data.frame <-
size.matrix <- function(x) prod(dim(x))
#' @export
#' @S3method size character
size.factor <-
size.character <- function(x) length(x)
#' @export
#' @S3method size integer
size.double <-
size.integer <- function(x) sum(x)
@S3method
如果不使用已弃用的指令,我无法找到导出矩阵、字符和整数方法的方法。有没有办法在不使用弃用指令的情况下导出这些方法?
谢谢!