1
行和列的名字,我想作爲R下列矩陣閱讀,但隨後放棄行和列名:閱讀矩陣,而不R中
A B C D
A 0 4562 50714 882
B 5718 2302 47 26
C 72055 82 5889 215
D 1930 41 85 396
我這樣做:
matrix1 <-read.table("matrix_min.csv", header=T, sep=",")
m <- as.matrix(matrix1)
但是,結果'm'仍然有行和列名稱。我如何擺脫它們?
出於某種原因,在閱讀文件中使用
matrix1 <-read.table("matrix_min.csv", header=T, sep=",")
m <- as.matrix(matrix1,row.names=0,col.names=0)
rownames(m) <- colnames(m) <- NULL
print(m)
生產:
[,1] [,2] [,3] [,4] [,5]
[1,] "A" " 0" "4562" "50714" "882"
[2,] "B" " 5718" "2302" " 47" " 26"
[3,] "C" "72055" " 82" " 5889" "215"
[4,] "D" " 1930" " 41" " 85" "396"
'rownames(米)< - colnames(米)< - NULL'? – rawr 2014-11-01 22:38:17
'dimnames(m)< - NULL' – 2014-11-01 22:41:13
感謝,由於某種原因,在讀取文件時使用了matrix1 <-read.table(「matrix_min.csv」,header = T,sep =「,」); rownames(矩陣1)產生[1]「1」「2」「3」「4」。不刪除'A'...'D'行名稱 – user308827 2014-11-01 22:42:08