将扩展名为.data的文件读入R中 [英] Read files with extension .data into R
问题描述
我需要将数据文件读入 R 作为我的作业。您可以从以下网站下载。
I need to read a data file into R for my assignment. You can download it from the following site.
http:// archive.ics.uci.edu/ml/datasets/Acute+Inflammations
数据文件以我从未看到的扩展名.data结尾。我尝试了read.table和相似,但无法正确读入 R 。有人可以帮我吗
The data file ends with an extension .data which I never see before. I tried read.table and alike but could not read it into R properly. Can anyone help me with this, please?
推荐答案
这是一个UTF-16的小端序文件,开头有一个字节顺序标记。 read.table
将失败,除非您指定正确的编码。这对我在MacOS上有用。小数用逗号表示。
It's a UTF-16 little endian file with a byte order mark at the beginning. read.table
will fail unless you specify the correct encoding. This works for me on MacOS. Decimals are indicated by a comma.
read.table("diagnosis.data", fileEncoding="UTF-16", dec=",")
V1 V2 V3 V4 V5 V6 V7 V8
1 35.5 no yes no no no no no
2 35.9 no no yes yes yes yes no
3 35.9 no yes no no no no no
这篇关于将扩展名为.data的文件读入R中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!