私はジェネリック関数( LINK、確かに私が把握するのは少し難しい)とこの質問(LINK )に基づいて正しく設定したと思うジェネリック印刷関数を持っています。ただし、チェックで警告が表示されます。以下は、モック関数、print メソッド、roxygen のドキュメント、およびチェックからのエラーです。print 関数が何をしているかの背景について。基本的に、出力がクラスのように見えないようにしたいのですが、後続の関数によってそのオブジェクトを処理するためのクラスが含まれています。警告を消す (そして印刷機能を維持する) にはどうすればよいですか?
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.