Print a matrix without row and column indices

无人久伴 提交于 2019-11-30 18:37:07
user1981275

The function prmatrix in the base package could work for this, it can take the arguments collab and rowlab:

prmatrix(diag(3), rowlab=rep("",3), collab=rep("",3))

 1 0 0
 0 1 0
 0 0 1

Another solution with function write.table

write.table(diag(3), row.names=F, col.names=F)

You can make it prettier by separating the columns with a tabulation

write.table(matrix(sample(1000,9),3,3), row.names=F, col.names=F, sep="\t")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!