Read.table and Fread

Hi All,

We have a file which is not reading via read.table but it is correctly reading via fread.
i m unable to attch the file here.The commands are as follows:
ReplicaVarience <-read.table(VarienceFilesList,stringsAsFactors = FALSE,header = FALSE,sep=",",skip = 1,quote="")

ReplicaVarience <-fread(VarienceFilesList,stringsAsFactors = FALSE,header = T,sep=",",quote = "")

It gives an error saying
;Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : </error><error> line 2312 did not have 12 elements</error><error>Calls: read.table -&gt; scan</error><error>Execution halted</error></CmdOutputWithActivityOutput></ns0:ErrorReport>

Please help me find the difference.

fread() from the data.table package has a whole bunch of features that distinguish it from base R read.table().
The wiki page linked to below has a list of "Convenience features of fread()".

It's hard to tell what exactly is going on without knowing what your data looks like, though. I would recommend just using it (fread()) over read.table() if it's working for your needs. It's more performant, too.

Here's the full documentation (which you can also always retrieve by entering ?fread in your R console)

Aside: You don't actually need to set stringsAsFactors = FALSE in the fread() command, since that is the default. It also has auto-detect for header and sep arguments.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.