我创建了一个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)
}
)
答案 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)
}
)