在R语言里,如何转化数据集?

2025-05-24 08:12:57
推荐回答(1个)
回答1:

用as.matrix, 如果数据类型都相符
> help(as.matrix)
> t<-read.delim("t.txt", header=T)
> t
t1 t2
1 1 2
2 15 33
> aMat<-as.matrix(t)
> aMat
t1 t2
[1,] 1 2
[2,] 15 33
> class(aMat)
[1] "matrix"