检查这个例子:
> a = matrix(1:9, nrow = 3, ncol = 3, dimnames = list(LETTERS[1:3], LETTERS[1:3]))
> a
A B C
A 1 4 7
B 2 5 8
C 3 6 9
该表正确显示。有两种不同的方式将其写入文件...
write.csv(a, 'a.csv')
如预期的那样:
"","A","B","C"
"A",1,4,7
"B",2,5,8
"C",3,6,9
和write.table(a, 'a.txt')
哪个拧
"A" "B" "C"
"A" 1 4 7
"B" 2 5 8
"C" 3 6 9
确实,缺少一个空白的标签....这对于下游事物来说是一个痛苦。这是错误还是功能?有解决方法吗?(除外write.table(cbind(rownames(a), a), 'a.txt', row.names=FALSE
)
干杯,扬尼克