tim
tim

Reputation: 3608

Does the roxygen2 package support tables?

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)
}

Upvotes: 6

Views: 1544

Answers (2)

Dason
Dason

Reputation: 61953

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

Upvotes: 4

Droplet
Droplet

Reputation: 1125

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.

Upvotes: 7

Related Questions