Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read tab delimited text file

Tags:

r

I am trying to read the data from this link in R using the following code but I keep getting warning messages and the dataframe doesn't read the data properly.

url <- 'https://onlinecourses.science.psu.edu/stat501/sites/onlinecourses.science.psu.edu.stat501/files/data/leukemia_remission.txt'
df <- read.table(url, sep = '\t',header = F, skip = 2,quote='', comment='')

Can you tell what I need to change to read the data

EDIT

Adding data snippet

REMISS  CELL    SMEAR   INFIL   LI  BLAST   TEMP
1   0.8 0.83    0.66    1.9 1.1 1
1   0.9 0.36    0.32    1.4 0.74    0.99
0   0.8 0.88    0.7 0.8 0.18    0.98
0   1   0.87    0.87    0.7 1.05    0.99
1   0.9 0.75    0.68    1.3 0.52    0.98
0   1   0.65    0.65    0.6 0.52    0.98
1   0.95    0.97    0.92    1   1.23    0.99
0   0.95    0.87    0.83    1.9 1.35    1.02
like image 431
Clock Slave Avatar asked Mar 15 '17 19:03

Clock Slave


1 Answers

It is an issue about encoding. Please see this thread for more information (Get "embedded nul(s) found in input" when reading a csv using read.csv()).

url <- 'https://onlinecourses.science.psu.edu/stat501/sites/onlinecourses.science.psu.edu.stat501/files/data/leukemia_remission.txt'
df <- read.table(url, sep = '\t',header = TRUE, fileEncoding = "UTF-16LE")
like image 82
www Avatar answered Sep 19 '22 16:09

www