通用打印功能roxygen2

时间:2012-12-04 02:15:16

标签: r roxygen2

我有一个通用的打印功能,我认为我已经根据通用函数(LINK正确设置了,对我来说有点难以理解)和这个问题(LINK)。但是,它仍然会在支票中发出警告。下面是模拟函数,打印方法,roxygen文档和检查中的错误。有关打印功能正在执行的操作的背景知识;基本上我希望输出看起来不像是类,但它仍然带有一个类,用于通过后续函数处理该对象。如何使警告消失(并保持打印功能)?

FUN <- function(x) {
    class(x) <- "full_matrix"
    x
}

#' Prints a fuul_matrix object
#' 
#' prints a test object
#' 
#' @param full_matrix The full_matrix object
#' @method print full_matrix
#' @S3method print full_matrix
print.full_matrix <- function(full_matrix) {
    x <- full_matrix
    class(x) <- NULL
    print(x)
}

x <- FUN(mtcars)
x
class(x)

警告:

* checking S3 generic/method consistency ... WARNING
print:
  function(x, ...)
print.full_matrix:
  function(full_matrix)

print:
  function(x, ...)
print.incomplete_matrix:
  function(incomplete_matrix)

See section 'Generic functions and methods' of the 'Writing R
Extensions' manual.

1 个答案:

答案 0 :(得分:2)

来自Writing R Extensions

  

方法必须包含泛型的所有参数,包括......如果泛型的参数。

您的方法既没有x也没有...

相关问题