【问题标题】:Reading .data file in r在 r 中读取 .data 文件
【发布时间】:2018-03-01 09:59:21
【问题描述】:

我需要读取一个 .data 类型的数据文件(可以找到here)。我以前从未见过或读过这样的文件,当我尝试 read.table(file = "ionosphere.data") 时,单个实例的所有属性都组合在一起。如何正确读取此文件?

【问题讨论】:

    标签: r dataset


    【解决方案1】:

    您只需在read.table 中指定分隔符:read.table("https://archive.ics.uci.edu/ml/machine-learning-databases/ionosphere/ionosphere.data", sep = ",")

    【讨论】:

      【解决方案2】:

      这是一个 UTF-16 文件,开头有一个字节顺序标记。除非您指定正确的编码,否则 read.table 将失败。这适用于我在 MacOS 上。小数点用逗号表示。

      read.table("ionosphere.data", fileEncoding="UTF-16", dec=",")
      

      【讨论】:

        【解决方案3】:

        您可以下载文件并输入x<-read.csv("D:/filedestination/ionosphere.data",header=F)查看数据view(ionosphere.data)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-06-29
          • 1970-01-01
          • 1970-01-01
          • 2021-12-06
          • 2017-02-25
          • 1970-01-01
          • 2021-08-04
          • 2016-06-25
          相关资源
          最近更新 更多