Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

NA values instead of empty cells #286

Closed GegznaV closed 7 years ago

GegznaV commented 7 years ago

Is there a way to replace NA values, which are placed in cells, which are empty before applying pander, with some other character (empty space, long dash, etc.).

E.g., tables of ANOVA models, summaries, etc., have those NA values:

library(pander)
data(chickwts)

pander(aov(weight~feed, chickwts))

Results in:

-----------------------------------------------------------
            Df   Sum Sq   Mean Sq   F value   Pr(>F)  
--------------- ---- -------- --------- --------- ---------
   **feed**      5    231129    46226     15.36   5.936e-10

 **Residuals**   65   195556    3009       NA        NA    
-----------------------------------------------------------

Table: Analysis of Variance Model

While

-----------------------------------------------------------
            Df   Sum Sq   Mean Sq   F value   Pr(>F)  
--------------- ---- -------- --------- --------- ---------
   **feed**      5    231129    46226     15.36   5.936e-10

 **Residuals**   65   195556    3009                     
-----------------------------------------------------------

Table: Analysis of Variance Model

is expected.

Long dashes should be fine too:

-----------------------------------------------------------
            Df   Sum Sq   Mean Sq   F value   Pr(>F)  
--------------- ---- -------- --------- --------- ---------
   **feed**      5    231129    46226     15.36   5.936e-10

 **Residuals**   65   195556    3009        —       —  
-----------------------------------------------------------

Table: Analysis of Variance Model

And

library(pander)
data(mtcars)

mtcars$am  <- as.factor(mtcars$am)

pander(summary(mtcars[c("disp","am")]))

results in:

------------------
    disp       am 
------------- ----
Min.  : 71.1  0:19

1st Qu.:120.8 1:13

Median :196.3  NA 

 Mean :230.7   NA 

3rd Qu.:326.0  NA 

Max.  :472.0   NA 
------------------

In stead of:

------------------
    disp       am 
------------- ----
Min.  : 71.1  0:19

1st Qu.:120.8 1:13

Median :196.3   

 Mean :230.7     

3rd Qu.:326.0   

Max.  :472.0     
------------------
GegznaV commented 7 years ago

oh, it's parameter missing ="".

Sorry for bothering.

pander(aov(weight~feed, chickwts), missing ="")