【发布时间】:2012-11-10 12:24:18
【问题描述】:
我在使用 Roxygen 的 checking 分配函数时遇到问题。
这是一个相当简单的例子:
#' 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)
}
当我运行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)
我不明白第二个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
}
我没有看到 check 声称的 (x, value, value) 签名。
这是一个 S3 函数,但它在 S4 对象上运行。我认为这仍然应该使它成为 S3。但如果不是,那可能是我对@S3method 的使用是问题所在。
帮助?
【问题讨论】:
-
这可能是因为 roxygen2 中的 S4 支持很烂 :( 你可以试试实验性的 roxygen3,它将在未来某个时候合并回 roxygen2。