gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 06:03:06 26 4
gpt4 key购买 nike

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

我有以下roxygen2在引用 S4 类的两个函数中(两个函数都返回此类的对象):

#' @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标签,我收到此警告,尽管我确实有一个链接:

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 "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 类文档中所看到的,请注意名称是 mod_imputeMulti-class,而不是 mod_imputeMulti

我需要添加“-class”。不需要 @aliases 标记。

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

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

关于r - S4 类交叉引用 - 什么是合适的语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36579892/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com