2012-11-10 5 views
6

Roxygen을 사용하여 check 할당 기능에 문제가 있습니다.할당 기능 문서가 실패합니다. R CMD CHECK

여기에 상당히 최소한의 예입니다 :

#' 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를 실행하면 두 번째 value가 어디에서 오는

* 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) 

이해가 안 돼요. 나는 을 제거하려고 시도했다. 아마 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) 
}