分配功能文档失败R CMD CHECK

Ari*_*man 7 r roxygen2

我在check使用Roxygen进行赋值功能时遇到了麻烦.

这是一个相当小的例子:

#' Get sp feature IDs
#' @aliases IDs IDs.default IDs.SpatialPolygonsDataFrame IDs<- IDs<-.SpatialPolygonsDataFrame
#' @param x The object to get the IDs from or assign to
#' @param value The character vector to assign to the IDs
#' @param \dots Pass-alongs
#' @author Ari B. Friedman
#' @rdname IDs
IDs <- function(x,...) {
  UseMethod("IDs",x)
}
#' @method IDs default
#' @S3method IDs default
#' @rdname IDs
IDs.default <- function(x,...) {
  stop("Currently only SpatialPolygonsDataFrames are supported.")
}
#' @method IDs SpatialPolygonsDataFrame
#' @S3method IDs SpatialPolygonsDataFrame
#' @rdname IDs
IDs.SpatialPolygonsDataFrame <- function(x,...) {
  vapply(slot(x, "polygons"), function(x) slot(x, "ID"), "")
}

#' Assign sp feature IDs
#' @rdname IDs
"IDs<-" <- function( x, value ) {
  UseMethod("IDs<-",x)
}
#' @method IDs<- SpatialPolygonsDataFrame
#' @S3method IDs<- SpatialPolygonsDataFrame
#' @rdname IDs
"IDs<-.SpatialPolygonsDataFrame" <- function( x, value) {
  spChFIDs(x,value)
}
Run Code Online (Sandbox Code Playgroud)

当我跑check:

* checking for code/documentation mismatches ... WARNING
Codoc mismatches from documentation object 'IDs':
IDs<-
  Code: function(x, value)
  Docs: function(x, value, value)
IDs<-.SpatialPolygonsDataFrame
  Code: function(x, value)
  Docs: function(x, value, value)
Run Code Online (Sandbox Code Playgroud)

我不明白第二个value来自哪里.我已经尝试消除@param value理论上可能Roxygen自动为赋值函数创建一个条目,但这并没有消除(x,value,value)定义并产生一个新的警告抱怨我没有定义value.

这是.Rd生成的相关部分:

\usage{
  IDs(x, ...)

  \method{IDs}{default} (x, ...)

  \method{IDs}{SpatialPolygonsDataFrame} (x, ...)

  IDs(x, value) <- value

  \method{IDs}{SpatialPolygonsDataFrame} (x, value) <-
    value
}
Run Code Online (Sandbox Code Playgroud)

我没有看到声称存在的(x, value, value)签名check.

这是一个S3功能,但它在S4对象上运行.我认为这应该仍然是S3.但如果不是,我的使用可能@S3method就是问题.

救命?

Das*_*son 5

这是一个相当骇人听闻的解决方法,但似乎暂时无法解决roxygen的处理方式(LINK)。但是您可以直接将用法部分添加到您的roxygen注释中。

#' Assign sp feature IDs
#' @rdname IDs
#' @usage IDs(x) <- value
"IDs<-" <- function( x, value ) {
    UseMethod("IDs<-",x)
}

#' @method IDs<- SpatialPolygonsDataFrame
#' @S3method IDs<- SpatialPolygonsDataFrame
#' @rdname IDs
#' @usage IDs(x) <- value
"IDs<-.SpatialPolygonsDataFrame" <- function( x, value) {
    spChFIDs(x,value)
}
Run Code Online (Sandbox Code Playgroud)