将扩展名为 .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/急性+炎症
数据文件以我从未见过的扩展名 .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 little endian 文件,开头有字节序标记.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屋!