llewmills
llewmills

Reputation: 3590

Blank Cells in Pander table

Is there any way to create a pander table in rmarkdown so that the cells with NA (e.g. the table below) appear completely blank?

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

Upvotes: 1

Views: 674

Answers (1)

daroczig
daroczig

Reputation: 28682

Yup, the missing argument is your friend:

> 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

Or enable that globally via 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

Upvotes: 2

Related Questions