简体   繁体   English

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

[英]R CMD check warning: Functions/methods with usage in documentation object … but not in code

I am writing a package but one persistent R CMD check warning prevents me from finishing the package and posting it to CRAN. 我正在编写一个包,但是一个持久的R CMD check警告阻止我完成包并将其发布到CRAN。 I use roxygen2 for inline documentation, although that possibly isn't the root cause of the error. 我使用roxygen2进行内联文档,尽管这可能不是错误的根本原因。

If you know what to do to remove this warning, I can quite possibly figure out a way of doing it using roxygen2 . 如果您知道如何删除此警告,我很可能会想出一种使用roxygen2

How can I remove the warning Functions/methods with usage in documentation object ... but not in code from my package checks? 如何删除 Functions/methods with usage in documentation object ... but not in code 的警告 Functions/methods with usage in documentation object ... but not in code 我的包检查 Functions/methods with usage in documentation object ... but not in code


The R CMD check warning: R CMD check警告:

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

The function and roxygen documentation: 功能和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)
}

The resulting .rd documentation file: 生成的.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.
}

I have cross-checked my documentation with the documentation for names<- in base R, and it seems identical: 我已经用基础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.}

Related question (but I have already implemented the suggestion and still no luck): 相关问题(但我已经实施了建议但仍然没有运气):


Where am I going wrong? 我哪里错了? How can I remove this warning from the package checks? 如何从包裹检查中删除此警告?

The \\usage section in the Rd file needs to include the following: Rd文件中的\\usage部分需要包含以下内容:

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

If this is not automatically inserted by the @method line (I presume that will only add \\method{names}{surveydata}(x) ?) then you need an explicit @usage section that includes the above. 如果这不是由@method行自动插入的(我假设只会添加\\method{names}{surveydata}(x) ?)那么你需要一个包含上述内容的显式@usage部分。 Something like 就像是

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

I would also change the @name and @alias sections to refer to the method explicitly not the generic as that will clash with the Rd file in R::base. 我还要更改@name@alias部分以明确引用该方法,而不是泛型,因为它将与R :: base中的Rd文件冲突。

Essentially, the warning is coming from the fact that your package doesn't contains a function "names<-" yet you are using this in \\usage{} . 本质上,警告来自于您的包包含函数"names<-"但您在\\usage{}中使用此函数的事实。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM