单身space迎合table
Single space pander table
如何将 pander 打印成单张 space,而不是双张。目前,如果我这样做:
pander(mtcars[1:5, 1:5])
我得到:
--------------------------------------------------------
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
--------------------------------------------------------
我怎样才能得到这个:
--------------------------------------------------------
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
--------------------------------------------------------
这是一个 hacky 方法:
single_print <- function(x, ...){
out <- capture.output(pander(x, ...))
cat(out[out != ''], sep = '\n')
}
single_print(mtcars[1:5, 1:5])
## --------------------------------------------------------
## 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
## --------------------------------------------------------
我已要求将此作为此处的功能:https://github.com/Rapporter/pander/issues/327
来自@daroczig 通过:https://github.com/Rapporter/pander/issues/327
pander::pander(mtcars[1:5, 1:5], style = 'simple')
## --------------------------------------------------------
## 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
## --------------------------------------------------------
如何将 pander 打印成单张 space,而不是双张。目前,如果我这样做:
pander(mtcars[1:5, 1:5])
我得到:
--------------------------------------------------------
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
--------------------------------------------------------
我怎样才能得到这个:
--------------------------------------------------------
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
--------------------------------------------------------
这是一个 hacky 方法:
single_print <- function(x, ...){
out <- capture.output(pander(x, ...))
cat(out[out != ''], sep = '\n')
}
single_print(mtcars[1:5, 1:5])
## --------------------------------------------------------
## 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
## --------------------------------------------------------
我已要求将此作为此处的功能:https://github.com/Rapporter/pander/issues/327
来自@daroczig 通过:https://github.com/Rapporter/pander/issues/327
pander::pander(mtcars[1:5, 1:5], style = 'simple')
## --------------------------------------------------------
## 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
## --------------------------------------------------------