【发布时间】:2020-10-25 10:35:00
【问题描述】:
我有一个文本文件名 "A.txt" 。在那里,我有以下数据:
1 3 4
2 3 4
5 6 7
我想阅读它并在 R 软件中另存为 A 向量。我怎样才能做到这一点 ?
更新:
我已经尝试过以下代码:
R> dat <- as.numeric(readLines('D:/Simplex/SimplexInitialTheoryWithRsoftware/src/A.txt'))
R> dat.matrix <- matrix(dat, nrow=??)
但我有以下错误。
错误:“dat.matrix
我是这个软件的新手。请帮帮我
【问题讨论】:
-
只需将
read.table读取为data.frame 并使用as.matrix(或unlist,如果你真的想要一个原子向量)。 -
罗兰,你能看到更新吗?
-
错误:“dat.matrix
-
@osimer pothe 你提到你想
read it and save as A vector。所以,我不明白matrix(dat, nrow=??)命令。
标签: r