Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

pander.ftable issues/not as pretty as pander.tabular? #273

Open bbolker opened 8 years ago

bbolker commented 8 years ago

I'd like to use pander.ftable as recommended e.g. here to get nice tabular output with dimnames (row/column names) preserved ... I'm having some difficulties (sorry/thanks for your patience if these are really rmarkdown rather than pander issues ...)

After I convert my tables via ftable(), I do get the dimnames preserved, but I lose a lot of the nice formatting - separator lines are missing, and the row/column names are no longer boldfaced. I've poked at this a little bit but haven't found an easy solution yet ... suggestions?

update: this helps a bit ...

pftab <- function(tt) {
    pander(ftable(tt),emphasize.strong.rows=1,emphasize.strong.cols=1)
}

but the results are still not as pretty as I'd like (justification, separators, ...)

daroczig commented 7 years ago

Good catch! This is because t1 has a header:

> pander::pander(t1)

----------------
 &nbsp;   A   B 
-------- --- ---
 **a**    6   4 

 **b**    4   6 
----------------

While f1 is a matrix with no header (eg the first line is just a normal line instead of being a header):

> pander::pander(f1)

---- ---- --- ---
      x2   A   B 

 x1              

 a         6   4 

 b         4   6 
---- ---- --- ---

Honestly, I'm not that familiar with the ftable class, so asking for help here. Should we always suppose that the first line of an ftable object should be rendered as a table header?