使用Pander在CrossTable中为数字添加逗号

时间:2016-06-13 16:20:49

标签: r knitr pander

我想使用pander为CrossTable中生成的数字添加逗号。根据pander :: pander.CrossTable,可以将选项传递给pandoc.table,并且有一个名为“big.mark”的选项来添加逗号。但以下不起作用:

require(pander)
require(descr)
panderOptions("big.mark", ",")
t1<-c(rep("a",1500),rep("b",1000))
t2<-c(rep("b",1200),rep("a",300), rep("c", 1000))
pander(CrossTable(t1,t2, prop.r=TRUE,  prop.c=FALSE, prop.t=FALSE, expected=FALSE, prop.chisq=FALSE, big.mark=panderOptions("big.mark")))

------------------------------------------------
 &nbsp;\    t2\     &nbsp;\   &nbsp;\   &nbsp;\ 
   t1        a         b         c       Total  
--------- -------- --------- --------- ---------
 **a**\   &nbsp;\  &nbsp;\   &nbsp;\   &nbsp;\  
   N\      300\     1200\      0\       1500\   
 Row(%)     20%       80%       0%        60%   

 **b**\   &nbsp;\  &nbsp;\   &nbsp;\   &nbsp;\  
   N\       0\       0\       1000\     1000\   
 Row(%)      0%       0%       100%       40%   

  Total     300      1200      1000      2500   
------------------------------------------------

关于如何在上述计数中添加逗号的任何想法?感谢

0 个答案:

没有答案