0

If I'm not wrong, there are two ways to create markdown tables with pander package: either use the pandoc.table() function or the generic function pander(). However with pander() function, it seems that you cannot use the arguments from pandoc.table()

For example :

library(pander)
data(iris)
pandoc.table(summary(iris), split.table="Inf")
pander(summary(iris), split.table="Inf")

With pandoc.table, the table is not split because of the argument split.table (that's the intended behavior). But with pander, the argument is ignored.
I see in the code of the function that the ... argument is present in pander.data.frame but is not respecified within it. :

> pander:::pander.data.frame
function (x, caption = attr(x, "caption"), ...)
{
    if (is.null(caption) & !is.null(storage$caption))
        caption <- get.caption()
    pandoc.table(x, caption = caption)
}

Why not reuse the ... argument inside the function to allow passing arguments from pander to pandoc.table (like below)? There is maybe a good reason for this of course...

function (x, caption = attr(x, "caption"), ...)
{
    if (is.null(caption) & !is.null(storage$caption))
        caption <- get.caption()
    pandoc.table(x, caption = caption,...)
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Gilles San Martin
  • 4,224
  • 1
  • 18
  • 31

1 Answers1

2

While processing pandoc.table arguments via the pander method is a reasonable idea (and I will definitely allow this solution in the next release, thanks for the question!), this can be also addressed more globally with general pander options. E.g.:

> library(pander)
> data(iris)
> panderOptions('table.split.table', 'Inf')
> pander(head(iris))

-------------------------------------------------------------------
 Sepal.Length   Sepal.Width   Petal.Length   Petal.Width   Species 
-------------- ------------- -------------- ------------- ---------
     5.1            3.5           1.4            0.2       setosa  

     4.9             3            1.4            0.2       setosa  

     4.7            3.2           1.3            0.2       setosa  

     4.6            3.1           1.5            0.2       setosa  

      5             3.6           1.4            0.2       setosa  

     5.4            3.9           1.7            0.4       setosa  
-------------------------------------------------------------------

Update [2013/06/11]: a recent commit resolved this issue and now you can pass those extra params to pandoc.table via pander S3 method:

> pander(summary(iris), split.table="Inf")

------------------------------------------------------------------------------
&nbsp;  Sepal.Length   Sepal.Width   Petal.Length   Petal.Width     Species   
------ -------------- ------------- -------------- ------------- -------------
 ****   Min.  :4.300  Min.  :2.000   Min.  :1.000  Min.  :0.100   setosa :50  

 ****  1st Qu.:5.100  1st Qu.:2.800 1st Qu.:1.600  1st Qu.:0.300 versicolor:50

 ****  Median :5.800  Median :3.000 Median :4.350  Median :1.300 virginica :50

 ****   Mean :5.843    Mean :3.057   Mean :3.758    Mean :1.199               

 ****  3rd Qu.:6.400  3rd Qu.:3.300 3rd Qu.:5.100  3rd Qu.:1.800              

 ****   Max.  :7.900  Max.  :4.400   Max.  :6.900  Max.  :2.500               
------------------------------------------------------------------------------
daroczig
  • 28,004
  • 7
  • 90
  • 124
  • Great if you can add it and thanks for developing pander ! I do use panderOptions but I specify it once at the beginning of the document and I would like to change occasionally the options, so for the moment i use pandoc.table instead. – Gilles San Martin Jun 11 '13 at 08:23
  • Thank you @Gilles for your kind words and please see my updated answer. – daroczig Jun 11 '13 at 20:24