Pander表中的空白单元格

时间:2016-06-24 21:42:06

标签: r r-markdown pander

有没有办法在rmarkdown中创建一个pander表,以便NA的单元格(例如下表)显示为完全空白?

---
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")
```

1 个答案:

答案 0 :(得分:2)

是的,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