我被要求更新我的包Bolstad
,以便我的S3中位数方法的定义与R 3.4.0中的新中位数通用一致。这意味着需要能够处理...
- 这很好,但我还需要它与roxygen2
一起使用。这是我的函数定义等。:
#' Median generic
#'
#' @param x an object.
#' @param na.rm Ideally if \code{TRUE} then missing values will be removed, but not currently used.
#' @param \ldots [>=R3.4.0 only] Not currently used.
#' @details If \code{x} is an object of class \code{Bolstad} then the posterior
#' median of the parameter of interest will be calculated.
#' @author James Curran
#' @method median Bolstad
#' @export
median.Bolstad =
if(is.na(match("...", names(formals(median))))) {
function(x, na.rm = FALSE) {
return(quantile(x, probs = 0.5))
}
}else{
function(x, na.rm = FALSE, ...) {
return(quantile(x, probs = 0.5))
}
}
这个条件定义似乎编译好了,但是当我通过devel版本的R运行它时,我得到一个代码不匹配警告,因为使用不允许......,即
Codoc mismatches from documentation object 'median.Bolstad':
median.Bolstad
Code: function(x, na.rm = FALSE, ...)
Docs: function(x, na.rm = FALSE)
Argument names in code not in docs:
...
任何帮助/建议表示赞赏。
答案 0 :(得分:0)
下面给出了CRAN上的解决方案(基于Kurt Hornik发给我的东西)。但是,它也有一个缺点,roxygen2
不会为中值函数生成帮助文件。
#' Median generic
#'
#' @param x an object.
#' @param na.rm Ideally if \code{TRUE} then missing values will be removed, but not currently used.
#' @param ... [>=R3.4.0 only] Not currently used.
#' @details If \code{x} is an object of class \code{Bolstad} then the posterior
#' median of the parameter of interest will be calculated.
#' @author James Curran
#' @method median Bolstad
if(is.na(match("...", names(formals(median))))) {
median.Bolstad = function(x, na.rm = FALSE) {
return(quantile(x, probs = 0.5))
}
}else{
median.Bolstad = function(x, na.rm = FALSE, ...) {
return(quantile(x, probs = 0.5))
}
}