如何读取R中带有不规则空格的数字

时间:2015-10-28 02:45:48

标签: r

我的数据在txt文件中,包含以下编号,如何读入R 我绑了fread但没有工作

Error in fread("x.txt") : 
  Expected sep (' ') but new line, EOF (or other non printing character) ends field 0 when detecting types (   first):  

以下是数据:

 2    3    3    2    1    2    3    2    3     2     1     3     1     2

 1     1     3     2     3     1     2     1     2     3     3     2

 3     1     1     1     2     1     1     3     1     2     2     2

 1     3     1     1     3     2     3     3     1     1     2     2

     1     3     2     3     2     1     3     1     1     1     3     1

    1     3     1     2     3     3     2     2     2     2     3     3

 1     3     2     3     2     3     2     2     2     1     3     1
3     2     1     2     2     3     3     2     3     2     3     3

 2      1

1 个答案:

答案 0 :(得分:0)

试试这个。

x <- scan("x.txt")
data <- as.data.frame(x)