如何在 Roxygen 中显示返回列表的元素?
How to display the elements of a returned list in Roxygen?
我可以通过输入多行 @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
具有我正在寻找的确切降价格式:
来自文档 - http://r-pkgs.had.co.nz/man.html#text-formatting
@return 用于记录由函数编辑的对象 return。对于列表,使用 \item{name
a}{description a} 描述列表的每个组件
由于 link 在已接受的答案中被破坏,我包含了一个简单的 roxygen
文档示例,用于提供列表作为 return 值的函数。
#' 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
)
}
假设您的包名为 mypackage
,当 运行 ?mypackage::myfunction
.
时,以上内容有助于生成类似于下面输出的文档
这是基于 link 到 R 包 - 对象文档 - 文本格式参考 sheet
我可以通过输入多行 @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
具有我正在寻找的确切降价格式:
来自文档 - http://r-pkgs.had.co.nz/man.html#text-formatting
@return 用于记录由函数编辑的对象 return。对于列表,使用 \item{name a}{description a} 描述列表的每个组件
由于 link 在已接受的答案中被破坏,我包含了一个简单的 roxygen
文档示例,用于提供列表作为 return 值的函数。
#' 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
)
}
假设您的包名为 mypackage
,当 运行 ?mypackage::myfunction
.
这是基于 link 到 R 包 - 对象文档 - 文本格式参考 sheet