Pander 中的空白单元格 table
Blank Cells in Pander table
有什么方法可以在 rmarkdown 中创建一个 pander table,使带有 NA
的单元格(例如下面的 table)完全空白?
---
title: "Untitled"
author: "Llew Mills"
date: "24 June 2016"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.width=12, fig.height=8, fig.path='Figs/',
echo=FALSE, warning=FALSE, message=FALSE, dev = 'pdf')
```
``` {r stuff}
library(pander)
m1 <- sample(1:10,6)
m2 <- sample(1:10,6)
m3 <- sample(1:10,6)
mR <- c("Group A", NA, NA, "Group B", NA, NA)
df <- data.frame(mR,m1,m2,m3)
pander(df, justify = "right", style = "simple")
```
是的,missing
参数是你的朋友:
> pander(df, justify = "right", style = "simple", missing = "")
mR m1 m2 m3
--------- ---- ---- ----
Group A 5 4 7
4 9 10
3 2 1
Group B 8 8 5
6 10 3
1 7 6
或通过panderOptions
全局启用:
> panderOptions('missing', '')
> pander(df, justify = "right", style = "simple")
mR m1 m2 m3
--------- ---- ---- ----
Group A 5 4 7
4 9 10
3 2 1
Group B 8 8 5
6 10 3
1 7 6
有什么方法可以在 rmarkdown 中创建一个 pander table,使带有 NA
的单元格(例如下面的 table)完全空白?
---
title: "Untitled"
author: "Llew Mills"
date: "24 June 2016"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.width=12, fig.height=8, fig.path='Figs/',
echo=FALSE, warning=FALSE, message=FALSE, dev = 'pdf')
```
``` {r stuff}
library(pander)
m1 <- sample(1:10,6)
m2 <- sample(1:10,6)
m3 <- sample(1:10,6)
mR <- c("Group A", NA, NA, "Group B", NA, NA)
df <- data.frame(mR,m1,m2,m3)
pander(df, justify = "right", style = "simple")
```
是的,missing
参数是你的朋友:
> pander(df, justify = "right", style = "simple", missing = "")
mR m1 m2 m3
--------- ---- ---- ----
Group A 5 4 7
4 9 10
3 2 1
Group B 8 8 5
6 10 3
1 7 6
或通过panderOptions
全局启用:
> panderOptions('missing', '')
> pander(df, justify = "right", style = "simple")
mR m1 m2 m3
--------- ---- ---- ----
Group A 5 4 7
4 9 10
3 2 1
Group B 8 8 5
6 10 3
1 7 6