R CMD检查警告:在文档对象中使用的功能/方法..但不是在代码中



我正在编写一个包,但一个持续的R CMD check警告阻止我完成包并将其发布到 CRAN。我将roxygen2用于内联文档,尽管这可能不是错误的根本原因。

如果您知道如何删除此警告,我很可能会找到一种使用 roxygen2 的方法。

如何从 包裹检查中删除警告Functions/methods with usage in documentation object ... but not in code


R CMD check警告:

* checking for code/documentation mismatches ... WARNING
Functions/methods with usage in documentation object 'names<-' but not in code:
  names<-

函数和roxygen文档:

#' Updates names and variable.labels attribute of surveydata.
#' 
#' @name names<-
#' @rdname names
#' @aliases names<- names<-.surveydata
#' @param x surveydata object
#' @param value New names
#' @method names<- surveydata
#' @usage names(x) <- value
"names<-.surveydata" <- function(x, value){
    invisible(NULL)
}

生成的.rd文档文件:

name{names<-}
alias{names<-}
alias{names<-.surveydata}
title{Updates names and variable.labels attribute of surveydata.}
usage{
  names(x) <- value
}
arguments{
  item{x}{surveydata object}
  item{value}{New names}
}
description{
  Updates names and variable.labels attribute of
  surveydata.
}

我已经将我的文档与 base R 中names<-的文档进行了交叉检查,它似乎相同:

title{  The Names of an Object}
name{names}
alias{names}
alias{names.default}
alias{names<-}
alias{names<-.default}
keyword{attribute}
description{Functions to get or set the names of an object.}

相关问题(但我已经实施了该建议,但仍然没有运气):

  • 如何使用 Roxygen正确记录来自不同包的泛型的 S3 方法?

我哪里出错了? 如何从包检查中删除此警告?

Rd 文件中的usage部分需要包含以下内容:

method{names}{surveydata}(x) <- value

如果@method行没有自动插入(我认为这只会添加method{names}{surveydata}(x)?),那么您需要一个包含上述内容的显式@usage部分。类似的东西

#' @usage \method{names}{surveydata}(x) <- value

我还会更改@name@alias部分以明确引用该方法而不是泛型,因为这将与 R::base 中的 Rd 文件冲突。

从本质上讲,警告来自这样一个事实,即您的软件包不包含函数"names<-"但您正在usage{}中使用它。

如果它对任何人有帮助,此错误也可能来自一个废弃的 Rd 文件,该文件的函数或数据对象不再存在。

最新更新