我想通过函数以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 = ","
)