You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

R包帮助文档@author字段显示不一致问题排查求助

自定义R包@author字段显示不一致问题排查求助

我正在开发自定义R包,所有函数的roxygen2注释均包含@title、@description等字段,且@author字段统一使用以下格式:

#' @author [MyName](MyWebsite), [ORCID id: 0000-0002-XXXX-XXXX](https://orcid.org/0000-0002-XXXX-XXXX)

多数函数的帮助文档中,@author字段正常显示为带超链接的格式:

MyName, ORCID id: 0000-0002-XXXX-XXXX

其中“MyName”链接至个人网站,“ORCID id: 0000-0002-XXXX-XXXX”链接至ORCID页面。但极少数函数的帮助文档中@author显示为:

MyName (www: https://www.XXX.XXX, ORCID id: 0000-0002-XXXX-XXXX)

已完成的排查工作

  • 所有函数的@author字段内容完全一致;
  • DESCRIPTION文件已配置Roxygen: list(markdown = TRUE);
  • 对比正常与异常函数生成的Rd文件,发现author部分代码完全相同:
\author{
\href{MyURL}{MyName}, \href{https://orcid.org/0000-0002-XXXX-XXXX}{ORCID id: 0000-0002-XXXX-XXXX}
}

示例代码

正常显示的函数

#' @title Retrieve statistics for general linear hypothesis tests (glht)
#'
#' @description This function computes an estimate, a confidence interval, and a p-value for a general linear hypothesis test.
#'
#' @param multcomp.object An object created with `multcomp::glht(model, a.1.row.model.matrix)
#' @param level A numeric vector specifying the confidence level for the confidence interval (default=0.95)
#'
#' @examples
#' set.seed(1)
#' predictor <- factor(c(sample(letters[1:4], 200, replace=TRUE, prob=c(0.4, 0.3, 0.2, 0.1)), sample(letters[1:4], 200, replace=TRUE, prob=c(0.1, 0.2, 0.3, 0.4))))
#' response <- c(runif(200, 0, 0.8), runif(200, 0.2, 1))
#' m <- lm(response ~ predictor)
#' multcomp.object <- multcomp::glht(m, matrix(c(0, 0, 1, -1), nrow=1))
#' glht.retriever(multcomp.object)
#' multcomp.object <- multcomp::glht(m, matrix(c(0, 0, 1, -1), nrow=1), alternative="less")
#' glht.retriever(multcomp.object)
#' multcomp.object <- multcomp::glht(m, matrix(c(0, 0, 1, -1), nrow=1), rhs=-0.08)
#' glht.retriever(multcomp.object)
#'
#' @return A numeric vector with the estimate defined by the model matrix for the model in question, its lower and upper 95% confidence interval, and a p-value for whether it significantly differs from 0
#'
#' @export
#'
#' @author [MyName](MyURL), [ORCID id: 0000-0002-XXXX-XXXX](https://orcid.org/0000-0002-XXXX-XXXX)

glht.retriever <- function(multcomp.object, level=0.95) {
   return(
      setNames(
         c(multcomp.object %>% confint(level=level) %>% "$"(confint),
           multcomp.object %>% summary %>% "$"(test) %>% "$"(pvalues) %>% as.numeric),
         c("estimate", "lwr", "upr", "p")))
}

异常显示的函数

#' @title Goodman & Kruskal's gamma
#'
#' @description This function computes Goodman & Kruskal's gamma.
#'
#' @param a.rbyc.table A table/matrix of frequencies with r rows and c columns
#' @param CI.level The desired confidence interval
#'
#' @examples
#' addmargins(a.rbyc.table <- matrix(c(70,10,10,15,60,15,10,20,35,5,10,40), ncol=4))
#' GoodmanKruskal.gamma(a.rbyc.table)
#'
#' @return A 5-element list with Goodman & Kruskal's gamma, its standard error, its z-score and p-value, and its lower and upper confidence interval boundaries
#'
#' @references Sheskin, David J. 2011. Handbook of parametric and non-parametric statistical procedures. 5th ed. Boca Raton, FL: Taylor & Francis (Test 32)
#'
#' @export
#'
#' @author [MyName](MyURL), [ORCID id: 0000-0002-XXXX-XXXX](https://orcid.org/0000-0002-XXXX-XXXX)

GoodmanKruskal.gamma <- function (
      a.rbyc.table,
      CI.level=0.95) {
   nc <- 0; for (i in 1:(nrow(a.rbyc.table)-1)) {
      for (j in 1:(ncol(a.rbyc.table)-1)) {
         nc <- nc + "*"(
            a.rbyc.table[i,j],
            sum(a.rbyc.table[
               (i+1):nrow(a.rbyc.table),
               (j+1):ncol(a.rbyc.table)]))
      }}
   nd <- 0; for (i in 1:(nrow(a.rbyc.table)-1)) {
      for (j in ncol(a.rbyc.table):2) {
         nd <- nd + "*"(
            a.rbyc.table[i,j],
            sum(a.rbyc.table[
               (i+1):nrow(a.rbyc.table),
               1:(j-1)]))
      }}
   gamma <- (nc-nd) / (nc+nd)
   se <- sqrt("/"(
      nc+nd,
      sum(a.rbyc.table) * (1-gamma^2)))^-1
   z <- gamma * sqrt((nc+nd)/(sum(a.rbyc.table)*(1-gamma^2)))
   list("Goodman & Kruskal's gamma"=gamma,
        "std. error"=se,
        "inferential stats"=c("z"=z, "p (2-tailed)"=2*(1-pnorm(abs(z)))),
        "confidence interval"=c(
           "lower"=gamma - qnorm(1-((1-CI.level)/2), lower.tail=TRUE) * se,
           "upper"=gamma + qnorm(1-((1-CI.level)/2), lower.tail=TRUE) * se))
}

请求排查导致@author字段显示不一致的原因。


内容的提问来源于stack exchange,提问作者user1657021

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 11:24:53