Does the roxygen2 package support tables?
Asked Answered
S

2

6

I'm wanting to try using markdown in .Rd files. I think I get that @md at the end of the documentation for a function makes it parse markdown. But not see this table appear, nor is the raw text appearing... Does roxygen support 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)
}
Subsidize answered 25/3, 2017 at 13:48 Comment(1)
It uses commonmark and I don't see anything about tables in their specs: spec.commonmark.org/0.27Fioritura
C
7

There is now support for markdown tables in roxygen2 since the 7.0.0 version (on CRAN since 2019-11-12):

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

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

You can read more about this in the dedicated roxygen2 vignette.

Connaught answered 29/1, 2020 at 14:48 Comment(1)
Thank you! However, to not forget to turn on markdown support first! ;-)Bealle
F
4

It seems this answer is out of date as this functionality was eventually added. Keeping the answer around for historical purposes.


# old answer follows

The roxygen2 package's documentation says it uses commonmark for it's markdown and there is nothing about tables in the 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 and we don't find any support for markdown tables.

So at least as of the time this answer is written the it seems the answer to your question is "no" to markdown tables.

With that said you can put tables in your documentation but you'll have to do it 'by hand' using LaTeX syntax: https://cran.r-project.org/doc/manuals/R-exts.html#Lists-and-tables

Fioritura answered 17/4, 2017 at 18:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.