2016-06-24 52 views
1

是否有任何方法可以在rmarkdown中創建pander表,以便NA(例如下表)的單元顯示爲完全空白?Pander表中的空白單元

--- 
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

是啊,在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 
+0

神奇。打開了大量的可能性。 Thankyou @daroczig! – llewmills