2012-11-10 10 views
6

check Roxygenで代入関数に問題があります。二valueがどこから来ている私は理解していない代入関数の文書化に失敗するR CMD 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) 

#' 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を実行します。

はここでかなり最小限の例です。私は理論上、@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の私の使用が問題になるかもしれません。

ヘルプ?

+5

それはおそらくだ実験[roxygen3](http://github.com/hadley/roxygen3/)の中でいくつかの点でバックroxygen2にマージされます将来は – hadley

+0

これは関連しているようです:http://stackoverflow.com/questions/8873514/documenting-setter-functions-with-roxygen – Dason

答えて

4

これはやっかいなことですが、roxygenがこれを処理する方法は、当面はまだ解消されています(LINK)。しかし、手動であなたのroxygenコメントに直接使用セクションを追加することができます。 roxygen2におけるS4のサポートはあなたが試すことができます:(吸うので

#' 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) 
} 
関連する問題