ascii包打印不必要的字符

时间:2013-09-24 23:10:09

标签: r

运行以下示例

require(ascii)
mat <- matrix(c(1,11,2,12),nrow=2)
rownames(mat)<-letters[1:2]
colnames(mat)<-letters[11:12]
tab<- as.table(mat)
ascitab <- ascii(tab,digits=0,align="r")
print(ascitab,type="t2t")

产生以下输出:

||     |    k |    l 
|   a |    1 |    2 
|   b |   11 |   12 
Warning messages:
1: In rep(rownames, length = nrow(x)) :
  'x' is NULL so the result will be NULL
2: In rep(colnames, length = ncol(x)) :
  'x' is NULL so the result will be NULL

有两个问题:

一开始的双垂直条不正确,它应该只有一个条。 警告很奇怪。该表格式合理。

将print语句更改为

print(ascitab,type="t2t",include.rownames=TRUE,include.colnames=TRUE)

无法解决问题。 有人可以帮忙吗?

我知道一个笨拙的解决方案,包括捕获和后处理输出, 但我希望看到一个干净的解决方案。

0 个答案:

没有答案