0

How can I make pander print as single space, not double. Curently, if I do:

pander(mtcars[1:5, 1:5])

I get:

--------------------------------------------------------
                    mpg    cyl   disp   hp    drat 
----------------------- ------ ----- ------ ----- ------
     **Mazda RX4**        21     6    160    110   3.9  

   **Mazda RX4 Wag**      21     6    160    110   3.9  

    **Datsun 710**       22.8    4    108    93    3.85 

  **Hornet 4 Drive**     21.4    6    258    110   3.08 

 **Hornet Sportabout**   18.7    8    360    175   3.15 
--------------------------------------------------------

How can I get this instead:

--------------------------------------------------------
                    mpg    cyl   disp   hp    drat 
----------------------- ------ ----- ------ ----- ------
     **Mazda RX4**        21     6    160    110   3.9  
   **Mazda RX4 Wag**      21     6    160    110   3.9  
    **Datsun 710**       22.8    4    108    93    3.85 
  **Hornet 4 Drive**     21.4    6    258    110   3.08 
 **Hornet Sportabout**   18.7    8    360    175   3.15 
--------------------------------------------------------
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
  • A (possibly-volatile) convoluted combination of `capture.output` and `grep`? ;-) – r2evans Oct 23 '18 at 18:40
  • 1
    I thought about that but was hoping I just am missing a parameter from the documentation – Tyler Rinker Oct 23 '18 at 18:51
  • I didn't suggest it as a good solution as much as a hack-workaround. I don't know enough about `pander`'s internals to provide anything other than that, sorry. (Ergo my smiley/wink.) – r2evans Oct 23 '18 at 18:53
  • Left a comment on the [GH ticket](https://github.com/Rapporter/pander/issues/327) -- I think you are looking for the `simple` table style instead of the default `multiline`. – daroczig Oct 30 '18 at 09:22

2 Answers2

0

Here's a hacky way:

single_print <- function(x, ...){
    out <- capture.output(pander(x, ...))
    cat(out[out != ''], sep = '\n')
}

single_print(mtcars[1:5, 1:5])

## --------------------------------------------------------
##         &nbsp;           mpg    cyl   disp   hp    drat 
## ----------------------- ------ ----- ------ ----- ------
##      **Mazda RX4**        21     6    160    110   3.9  
##    **Mazda RX4 Wag**      21     6    160    110   3.9  
##     **Datsun 710**       22.8    4    108    93    3.85 
##   **Hornet 4 Drive**     21.4    6    258    110   3.08 
##  **Hornet Sportabout**   18.7    8    360    175   3.15 
## --------------------------------------------------------

I have asked this to be a feature here: https://github.com/Rapporter/pander/issues/327

Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
0

From @daroczig via: https://github.com/Rapporter/pander/issues/327

pander::pander(mtcars[1:5, 1:5], style = 'simple')

## --------------------------------------------------------
##         &nbsp;           mpg    cyl   disp   hp    drat 
## ----------------------- ------ ----- ------ ----- ------
##      **Mazda RX4**        21     6    160    110   3.9  
##    **Mazda RX4 Wag**      21     6    160    110   3.9  
##     **Datsun 710**       22.8    4    108    93    3.85 
##   **Hornet 4 Drive**     21.4    6    258    110   3.08 
##  **Hornet Sportabout**   18.7    8    360    175   3.15 
## --------------------------------------------------------
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519