0
$\begingroup$

I am trying to read a txt file in R but always I am getting

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 113 did not have 10 elements

I noticed that in the header of my file I have something like

 0000775 €   g¿´�€   4_®™00000016125 13404727020 017402  0                                                                                                    ustar   devons01                        stlab-icgc 

Even by removing these characters I am not able to read this file

This is link of my file

https://www.dropbox.com/s/rpc5jgti5aa433b/txt.txt?dl=0

Could somebody please heap me in reading this file in R?

$\endgroup$
1
  • 2
    $\begingroup$ Where is the file from, how was it generated? Looks like an XY Problem. $\endgroup$
    – zx8754
    May 8 '19 at 20:21
2
$\begingroup$

Delete the corrupt portion preceeding CFS in the header and it works with with read.delim().

$\endgroup$
5
  • $\begingroup$ Sorry where is the corrupt portion preceeding CFS ? $\endgroup$
    – Exhausted
    May 8 '19 at 11:58
  • $\begingroup$ Everything before it. Just open it in a text editor. $\endgroup$
    – Devon Ryan
    May 8 '19 at 11:59
  • $\begingroup$ @DevonRyan Couldn't it be a different encoding used? $\endgroup$
    – llrs
    May 8 '19 at 12:39
  • $\begingroup$ @llrs No, there was just a bunch of gibberish. It looks like some other content got added to the front of the file. $\endgroup$
    – Devon Ryan
    May 8 '19 at 12:43
  • $\begingroup$ Ok, it's simply when I see this question marks I always suspect of wrong encoding... $\endgroup$
    – llrs
    May 8 '19 at 12:51
3
$\begingroup$

We can skip the first row:

read.delim("txt.txt", skip = 1, header = FALSE)

Or we can get the "uncorrupted" version of the table, it looks like it is from this paper, Table S4.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.