我希望通过csv
函数以write.table
格式保存矩阵。使用以下命令,列名称将一个单元格移回。有没有办法保持列名完整?感谢
mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE,
dimnames = list(c("row1", "row2"),
c("C.1", "C.2", "C.3")))
mdat
write.table(
x=mdat
, file = "mdat.csv"
, sep = ","
)
答案 0 :(得分:0)
这个怎么样?:
write.table(
x=mdat
, file = "mdat.csv"
, sep = ",",row.names=c("row1","row2")
)