[英]Insert markdown table in roxygen2 R package documentation
I'm writing an R package and I want to include a table in an R help file, eg in the @details
section.我正在编写一个 R 包,我想在 R 帮助文件中包含一个表,例如在
@details
部分。 I tried including markdown code directly:我尝试直接包含降价代码:
#' | Tables | Are | Cool |
#' | ------------- |:-------------:| -----:|
#' | col 3 is | right-aligned | $1600 |
#' | col 2 is | centered | $12 |
But this does not give me the desired output.但这并没有给我想要的输出。 I have enabled markdown support for the whole package and have roxygen2 6.0.1 installed.
我已经为整个包启用了降价支持并安装了 roxygen2 6.0.1。 Is there no support for markdown tables?
不支持降价表吗? Do I have to use
\\tabular{}
?我必须使用
\\tabular{}
吗?
You need to add the @md
tag to your roxygen chunk您需要将
@md
标签添加到您的 roxygen 块中
#' @details
#' The table is:
#'
#' | Tables | Are | Cool |
#' | ------------- |:-------------:| -----:|
#' | col 3 is | right-aligned | $1600 |
#' | col 2 is | centered | $12 |
#'
#' @md
or add Roxygen: list(markdown = TRUE)
to your DESCRIPTION
file.或将
Roxygen: list(markdown = TRUE)
到您的DESCRIPTION
文件中。
Note that {roxygen} generates R Documentation files in the end.请注意,{roxygen} 最后会生成 R 文档文件。 Thus, you can always go to the Writing R Extensions: Lists and tables and write the table in the native documentation language for R-packages by hand.
因此,您可以随时访问“ 编写 R 扩展:列表和表格”,并使用 R 包的本机文档语言手动编写表格。
Here's a minimal example:这是一个最小的例子:
\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
}
}
Note, that the latest {roxygen2} version 7.0 provides more support for markdown-syntax.请注意,最新的 {roxygen2} 7.0 版为 markdown-syntax 提供了更多支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.