user1657021
user1657021

Reputation: 31

Display of author information in R package help file

I am creating my own package in R. For every function I define there, I have a roxygen2 file that with the following fields:

#' @title
#' @description
#' @param
#' @examples
#' @return
#' @export
#' @author

In all function files, the @author field looks like this:

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

However, the help files for functions do not display the author field in the same way. Most help files look like this:

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

where

HOWEVER, in a very very small number of help files the @author field (in RStudio) looks like this:

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

I've consulted AIs but no progress:

\author{
\href{MyURL}{MyName}, \href{https://orcid.org/0000-0002-XXXX-XXXX}{ORCID id: 0000-0002-XXXX-XXXX}
}

but are still displayed differently.

I am wondering whether it's something in the roxygen file before the @author field, but no matter how much I look at it, I can't see anything. Any ideas on what I might be missing?

Here's one function that works in the help file:

#' @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")))
}

This one doesn't:

#' @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))
}

Upvotes: 0

Views: 51

Answers (0)

Related Questions