Skip to content

COPY THIS Proposal Template

Toby Dylan Hocking edited this page Feb 9, 2015 · 1 revision

Turning R objects into Pandoc's markdown

Summary: Extending the pander package with new methods to render R objects easily in markdown. Refactor pandoc.table.

Description: pander contains helper functions and a generic S3 method to render various types of R objects into markdown format that can be converted further to HTML, PDF, docx, odt and other document formats based on pandoc. The package can be used as a standalone tool for literate programming building on the traditions of brew, or can be also used inside of e.g. knitr or other markdown-based tools to render nice tables and other textual forms. To see the currently supported classes, run:

> methods(pander)
 [1] pander.anova*           pander.aov*             pander.aovlist*    

Related work: Similar packages like xtable provides an alternative solution by already supporting more R classes, but e.g. xtable can only return HTML or LaTeX syntax, which is out of scope in general markdown documents to be converted to various file formats. Another similar solution can be found bundled with knitr, but kable is a very simple table generator by design, so pander can be a great add-on. In most cases, implementing the pander method of an R class is simply writing a wrapper around summary or checking the examples of xtable, stargazer or broom, but some classes require special treatment (like CrossTable) due to the limitations of markdown. For example Pandoc's markdown does not support row and column-spanning.

Potential tasks:

  • create new pander methods for not yet supported R classes
  • implement new global options for tables and plots
  • refactor pandoc.table to handle the variety of R objects (named vectors, tables, 2D tables, 3D crosstables and ftable objects) by transforming those to a standard format first instead of the currently active continuous checks and workarounds
  • refactor Pandoc.brew (forked from brew)
  • improve error handling and logging facilities

Skills required: literate programming experiences, so decent markdown and R experience is needed. In more details:

  • Pandoc's markdown syntax and the pandoc command line,
  • previous experience with brew or pander packages,
  • at least a basic git knowledge (e.g. branching) and experience with GitHub.

Test: Fork the package on GH and create a pull-request implementing a method for tables::tabular. Quick and dirty solution:

> library(tables)
> pander(as.matrix(tabular(as.factor(am) ~ (mpg+hp+qsec) * (mean+median), data = mtcars)))

------------- ----- ------ ----- ------ ----- ------
               mpg          hp          qsec        

as.factor(am) mean  median mean  median mean  median

      0       17.15  17.3  160.3  175   18.18 17.82 

      1       24.39  22.8  126.8  109   17.36 17.02 
------------- ----- ------ ----- ------ ----- ------

Please note that pander.tabular should work with any number of variables with even complex table layouts.

Mentor: Gergely Daróczi ([@](mailto:daroczig {at} rapporter {dot} net)) and László Szakács ([@](mailto:cocinerox {at} gmail {dot} com)) as backup mentor

Disclaimer: this proposal was partially covered in 2013 and 2014. Looking forward to work with such talented student again this year.

Clone this wiki locally