S4 class 交叉引用 - 什么是合适的语法?

S4 class cross-references - what is appropriate syntax?

我正在编写一个 R 包,目前 运行 R CMD check 通过 devtools::check()

我在 两个 函数中有以下 roxygen2 引用 S4 class(两个函数 return 这个 class):

#' @return An object of class \code{\link{mod_imputeMulti}}
#' @aliases mod_imputeMulti
#' @seealso \code{\link{multinomial_em}}, \code{\link{multinomial_impute}}

但我收到以下警告:

Rd files with duplicated alias 'mod_imputeMulti':
'multinomial_data_aug.Rd' 'multinomial_em.Rd'

如果我不使用第二行 -- @aliases 标签,我会收到此警告,尽管我 do 有一个 link:

checking Rd cross-references ... WARNING
Missing link or links in documentation object 'multinomial_data_aug.Rd': 'mod_imputeMulti'

Missing link or links in documentation object 'multinomial_em.Rd': 'mod_imputeMulti'

See section 'Cross-references' in the 'Writing R Extensions' manual.

注意:将 \code{\link{mod_imputeMulti}} 添加到 @seealso 不会更改此(第二个)警告

正确的语法是什么?

我看了很多参考资料,但找不到任何解决方案:

我希望这对某些人来说是一个简单的问题——在此先感谢您的帮助!

编辑:

S4 class 文档如下:

#' Class "mod_imputeMulti"
#'  
#' @name mod_imputeMulti-class
#' @description A multivariate multinomial model imputed by EM or Data Augmentation is 
#' represented as a \code{\linkS4class{mod_imputeMulti}} object. A complete 
#' dataset and model is represented as an \code{\linkS4class{imputeMulti}} object.
#' Slots for \code{mod_imputeMulti} objects include: (1) the modeling method; 
#' (2) the call to the estimation function; (3) the number of iterations in estimation;
#' (4) the final log-likelihood; (5) the conjugate prior if any; (6) the MLE estimate of
#' the sufficient statistics and parameters.
#' @docType class
#' @section Objects from the class: Objects are created by calls to
#' \code{\link{multinomial_impute}}, \code{\link{multinomial_em}}, or
#' \code{\link{multinomial_data_aug}}.
#' @seealso \code{\link{multinomial_impute}}, \code{\link{multinomial_em}}, 
#' \code{\link{multinomial_data_aug}}
#' @export
setClass("mod_imputeMulti",
         representation= list(
           method= "character",
           mle_call= "call",
           mle_iter= "numeric",
           mle_log_lik= "numeric",
           mle_cp= "character",
           mle_x_y= "data.frame"),
         validity= function(object) {
           if (!object@method %in% c("EM", "DA", "NULL")) {
             return("Currently only EM and DA methods are defined.")
           } else if (object@mle_iter < 0) {
             return("A negative iteration was given.")
           }
           return(TRUE)
         }
)

是的,这是一个相对简单的修复。

正如您在 OP 底部的 S4 class 文档中看到的那样,请注意名称是 mod_imputeMulti-class,而不是 mod_imputeMulti

我需要添加 "-class"。不需要 @aliases 标签。

#' @return An object of class \code{\link{mod_imputeMulti-class}}

此外,感谢@thomas 指出使用 @slotroxygen2 标记正确翻译成 man/*.Md 文件。