r - 如何记录 R6 类的 S3 泛型?

标签 r roxygen2 r6

我有一个 R6 类 myclass,并且我已为其定义了 S3 通用 as.matrix。一切正常,但当我运行 R CMD 检查时,我收到 2 个注释:

注1:

  S3 methods shown with full name in documentation object 'as.matrix.myclass':
    'as.matrix.myclass'

  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.

注2:

Found the following apparent S3 methods exported but not registered:
    as.matrix.myclass
  See section 'Registering S3 methods' in the 'Writing R Extensions'
  manual.

以下是我如何定义和记录 S3 泛型(这在 R6 类之外):

#' Converts all cores to R matrices
#'
#' @param x \code{myclass}
#' @param ... other arguments passed to \code{as.matrix()}
#' @return A named list of R matrices.
#' @export

as.matrix.myclass <- function(x, ...) {
  sapply(
    x$cores,
    function(x, ...) as.matrix(x, ...),
    USE.NAMES = TRUE, simplify = FALSE
  )
}

我正在使用支持 R6 文档的较新版本的 roxygen,但我找不到任何有关如何删除这些注释的信息。谢谢!

最佳答案

正如 @Mikko 所建议的,我更新了 roxygen 的版本(我原来的帖子现在已经相当旧了)。在 7.1.1 中,我不再收到注释。谢谢!

关于r - 如何记录 R6 类的 S3 泛型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61351475/

相关文章:

r - 调试 Roxygen 2 文档

r - 在构建 R 包期间没有创建手动 pdf

roxygen2 不创建 .Rd 文档

r - "User"R中R6类的构造函数

r - 如何在 R 中使用省略号传递参数并在另一个环境中求值

mysql - 带计算算法的 SQL 查询

r - 当目录包含大量无关文件时,如何提高 R CMD 构建的速度?

r - 在 R6 类中包装 Shiny 的模块

r - 如何告诉R6类如何使用方括号?

r - dnorm() 如何在 sapply 循环中处理分位数向量