Reading files with a .data extension in R

I need to read a data file in R for my destination. You can download it from the following site.

http://archive.ics.uci.edu/ml/datasets/Acute+Inflammations

The data file ends with a .data extension that I have never seen before. I tried read.table so, but could not read it correctly in the R . Can someone help me with this please?

+3
source share
4 answers

This is a small final UTF-16 file with a byte of byte order at the beginning. read.tablewill fail if you do not specify the correct encoding. This works for me on macOS. Decimal numbers 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
+3

:

ASCII. TAB.

, read.table() sep = "\t"

- : , '35, 9 ': '35, 9' '' "" "" ( ) "" "" , , "": "":

, , dec = "," read.table().

, , .

, @Gavin Simpson , "" .

+3

UTF-16LE, a.k.a Unicode Windows ( , os).

f <-file("http://archive.ics.uci.edu/ml/machine-learning-databases/acute/diagnosis.data", open="r" ,encoding="UTF-16LE")
data <- read.table(f, dec=",", header=F)

Although trying what @Gavin Simpson said may help, as you can add your headers and save the file

+3
source

The above answers are very helpful. A little more complicated is that you can simply rename the file name or file type to .csv format. Then, with the read.csv command, you can do the rest.

0
source

All Articles