从软件包文档中跳过参数而无警告

时间:2018-12-23 08:31:26

标签: r package documentation roxygen2

我创建了一个R程序包,并使用一些默认值设置为NULL的参数设置了通用名称。这些参数不是由用户提供的,因此我想从文档中跳过它们(使用roxygen2),但不会导致在R CMD check中收到警告。

一个例子:

#' Do that with myFoo...
#' 
#' `myFoo` ...
#' 
#' `myFoo` description...
#' 
#' @param object An object of myBar class
#' @param a A numeric value...
#' 
#' @return Smth
#' 
#' @name myFoo
#' @export
#' 
methods::setGeneric("myFoo", function(object, a, b=NULL, c=NULL) standard("myFoo"))


# User level
methods::setMethod(f="myFoo",
    signature=signature(object="myBar", a="numeric"),
    function(object, a, b, c){

            Some checks...

            b <- smth
            c <- smth

            return(myFoo(object@myBarItem, a, b, c))
    }
)


# For "iternal" use
methods::setMethod(f="myFoo",
    signature=signature(object="myBar2", a="numeric", b="character", c="matrix"),
    function(object, a, b, c){

            Smth

            return(someValue)
    }
)

1 个答案:

答案 0 :(得分:0)

看来,@rdname@aliases的添加解决了这个问题。

#' Do that with myFoo...
#' 
#' `myFoo` ...
#' 
#' `myFoo` description...
#' 
#' @param object An object of myBar class
#' @param a A numeric value...
#' 
#' @return Smth
#'
#' @name myFoo
#' @rdname myFoo
#' @export
#'
#' @aliases myFoo,myBar,numeric,ANY,ANY-method
#' myFoo,myBar2,numeric,character,matrix-method
#' 
#' @importFrom methods setGeneric setMethod
#'
methods::setGeneric("myFoo", function(object, a, b=NULL, c=NULL) standard("myFoo"))


# User level
methods::setMethod(f="myFoo",
    signature=signature(object="myBar", a="numeric"),
    function(object, a, b, c){

            Some checks...

            b <- smth
            c <- smth

            return(myFoo(object@myBarItem, a, b, c))
    }
)


# For "iternal" use
methods::setMethod(f="myFoo",
    signature=signature(object="myBar2", a="numeric", b="character", c="matrix"),
    function(object, a, b, c){

            Smth

            return(someValue)
    }
)