roxygen2 包是否支持表格?

Does the roxygen2 package support tables?

我想尝试在 .Rd 文件中使用 markdown。 我想我在函数文档的末尾得到了 @md,它使它解析降价。但是没有看到这个 table 出现,也没有出现原始文本...... roxygen 支持 tables 吗?

#' makes bar
#' @description
#' prints 2 x
#' @details see this table
#' 
#' |a |b |c |
#' |--|--|--|
#' |1 |3 |4 |
#'
#' @param x how much foo
#' @return - 
#' @export
#' @family tmp
#' @examples
#' foo(2)
#' @md
foo <- function(x) {
    print(2 * x)
}

似乎这个答案已经过时了,因为这个功能最终被添加了。出于历史目的保留答案。


# 个旧答案如下

roxygen2 包的文档说它使用 commonmark 作为 markdown,commonmark specs as of right now. On top of that we can examine the code related to markdown for the roxygen2 package here and here 中没有关于表格的内容,我们也没有找到任何对 markdown 表格的支持。

所以至少在撰写此答案时,您的问题的答案似乎是 "no" 降价表。

话虽如此,您可以在文档中放置表格,但您必须 'by hand' 使用 LaTeX 语法:https://cran.r-project.org/doc/manuals/R-exts.html#Lists-and-tables

roxygen2 since the 7.0.0 version(自 2019 年 11 月 12 日起在 CRAN 上)现在支持降价表:

Markdown tables are converted to a \tabular{} macro (#290). roxygen2 supports the GFM table syntax which looks like this:

| foo | bar | 
| --- | --- | 
| baz | bim | 

您可以在 dedicated roxygen2 vignette 中阅读更多相关信息。