【问题标题】:Insert markdown table in roxygen2 R package documentation在 roxygen2 R 包文档中插入降价表
【发布时间】:2017-03-15 14:52:55
【问题描述】:

我正在编写一个 R 包,我想在 R 帮助文件中包含一个表,例如在@details 部分。我尝试直接包含降价代码:

#' | Tables        | Are           | Cool  |
#' | ------------- |:-------------:| -----:|
#' | col 3 is      | right-aligned | $1600 |
#' | col 2 is      | centered      |   $12 |

但这并没有给我想要的输出。我已经为整个软件包启用了降价支持并安装了 roxygen2 6.0.1。不支持降价表吗?我必须使用\tabular{}吗?

【问题讨论】:

标签: r markdown roxygen2


【解决方案1】:

您需要将 @md 标签添加到您的 roxygen 块中

#' @details
#' The table is: 
#'
#' | Tables        | Are           | Cool  |
#' | ------------- |:-------------:| -----:|
#' | col 3 is      | right-aligned | $1600 |
#' | col 2 is      | centered      |   $12 |
#' 
#' @md

或将Roxygen: list(markdown = TRUE) 添加到您的DESCRIPTION 文件中。

【讨论】:

    【解决方案2】:

    请注意,{roxygen} 最终会生成 R 文档文件。因此,您可以随时访问Writing R Extensions: Lists and tables 并以本地文档语言为 R 包手动编写表格。

    这是一个最小的例子:

    \name{dummy}
    \title{Dummy}
    \details{
      The example here is:
    \tabular{lcc}{
      Tables   \tab  Are           \tab Cool   \cr
      col 3 is \tab  right-aligned \tab $1600  \cr
      col 2 is \tab  centered      \tab  $12   \cr
     }
    }
    

    请注意,最新的 {roxygen2} 版本 7.0 提供了对 markdown-syntax 的更多支持。

    【讨论】:

    • 是的。使用 roxygen2 7.0 版,问题中的代码现在应该可以正常工作了。
    猜你喜欢
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    • 2013-09-24
    • 1970-01-01
    • 2021-06-08
    • 2013-02-04
    • 2014-10-18
    • 1970-01-01
    相关资源
    最近更新 更多