如何在Roxygen中显示返回列表的元素?

问题描述 投票:8回答:2

我可以通过输入参数轻松地通过多行@param这样做:

#' @param var1 This is for x
#' @param var2 This is for y
#' @param var3 This is for Z

但是,如何为要返回的列表元素执行此操作。我想要包含每个元素的名称和关于它们的描述。将@return@param链接在一起并不具有相同的行为。什么是合适的标签?

#' @return A list with the following elements:
#' @something element1 Contains x
#' @something element2 Contains y
#' @something element3 Contains z

samr具有我正在寻找的确切降价格式:

enter image description here

r roxygen2
2个回答
8
投票

从手册 - http://roxygen.org/roxygen2-manual.pdf

@return用于记录函数返回的对象。对于列表,使用\ item {name a} {description a}描述列表的每个组件


2
投票

由于链接在另一个答案中被破坏,我提供了一个简单的roxygen文档示例,用于提供列表作为返回值的函数。

#' Sample function that returns a list and uses roxygen documentation.
#'
#'
#' @return A list with letters and numbers.
#' \itemize{
#'   \item A - The letters of the alphabet.
#'   \item B - A vector of numbers.
#' }
myfunction <- function() {
  list(
    A = LETTERS,
    B = 1:10
  )
}

这是基于与qazxsw poi的链接

© www.soinside.com 2019 - 2024. All rights reserved.