0

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

1 回答 1

0

那这个呢?:

write.table(
 x=mdat
 , file = "mdat.csv"
 , sep = ",",row.names=c("row1","row2")
)
于 2013-05-18T14:19:32.310 回答