1

Is there any way of having pander using only the necessary amount of rows in splitted summary-tables (instead of always using the maximum number of rows)?

This issue arises when there is a summary of a data.frame having for example numeric and logic columns: The numeric column needs 6 or 7 rows (depending on wether there are NAs or not), the logic column only 3.

df <- data.frame(a=1:10,
                 b=c(TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE))
summary(df)

Output:

        a             b          
 Min.   : 1.00   Mode :logical  
 1st Qu.: 3.25   FALSE:4        
 Median : 5.50   TRUE :6        
 Mean   : 5.50   NA's :0        
 3rd Qu.: 7.75                  
 Max.   :10.00  

Now, if I pander this, the empty rows get padded as NA, since class(summ) is c("summaryDefault", "table"). This can be avoided by setting missing to "", but then there are empty rows. This is OK if the summary is not splitted, but if the summary is splitted it happens that there are only empty rows in one block, which takes space and doesn't look good.

pander (summary( df),missing="",split.table = 20 )

Output:

-------------
      a      
-------------
Min.  : 1.00 

1st Qu.: 3.25

Median : 5.50

 Mean : 5.50 

3rd Qu.: 7.75

Max.  :10.00 
-------------

Table: Table continues below


-------------
      b      
-------------
Mode :logical

   FALSE:4   

   TRUE :6   

   NA's :0   




-------------
TylerH
  • 20,799
  • 66
  • 75
  • 101
Julian
  • 741
  • 8
  • 19
  • It seems to me that you'd like to have separate `summary` tables rendered in markdown. Then why not call `summary` on variables separately (and pass those to `pander`) instead of trying to do this on the `data.frame` basis? `summary(df)` is a `table` with `6x2` cells. – daroczig Dec 17 '14 at 10:06
  • OF course this would be a solution, but it would need to manually figure out how many variables to put in one table... It's because I (lazy) as I am, print a summary of the whole data.frame, and would like to take advantage of the 'split.table' function... – Julian Dec 17 '14 at 10:34
  • in this case I'd rather use `pander(sapply(df, summary))` – daroczig Dec 17 '14 at 11:35
  • Yes, this makes sense. FOR OTHERS: There is an issue with pander not printing column headers for single-vector-summaries like `pander(sapply(df, summary))`. See: https://github.com/Rapporter/pander/issues/143 . In the newest version from github this is solved, and then I can use the sapply-version. – Julian Dec 17 '14 at 12:35

0 Answers0