首页 > 代码库 > R:从文本文件读取矩阵
R:从文本文件读取矩阵
在~下有一文本文件matrix.dat内容如下:
https://stat.ethz.ch/pipermail/r-help/2006-June/108227.html
99 102 3 12 43 213.0 12 12 2 23 21 211
> A <- matrix(scan("~/matrix.dat", n = 3*4), 3, 4, byrow = TRUE) Read 12 items > A [,1] [,2] [,3] [,4] [1,] 99 102 3 12 [2,] 43 213 12 12 [3,] 2 23 21 211
> A <- as.matrix(read.table("matrix.dat")) > A V1 V2 V3 [1,] 99 102 3 [2,] 12 43 213 [3,] 12 12 2 [4,] 23 21 211
https://stat.ethz.ch/pipermail/r-help/2006-June/108227.html
R:从文本文件读取矩阵
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。