You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, while read.table properly handles reading the content with sep="\t", data.table::fread produces a data.table with wrongly-typed columns, some of them coerced to character due to white-space characters 0x20 while they truly are numeric or integer when such white-spaces are properly trimmed.
Could you please provide a direct link to your file? I don't manage to get the file loaded properly from the gist.
mattdowle
changed the title
fread handles whitespace column separator inconsistently with read.table
Support variable length whitespace delimiter in fread, as read.table does
Dec 16, 2014
Also requested by Bill at Budapest R User Group meetup.
I'm trying to import a large .txt. file using fread(), but this file contains a variable number of spaces between columns. Is there any way to do this with fread()? I've tried sep = "", sep = " ", sep = "x20" all to no avail. The function read.table() defaults to sep = "" (which is whitespace), but read.table() is far slower than fread(). Any help appreciated, Thanks! Bill.
I have hundreds of
txt
delim tables like this:https://gist.github.com/renqian/d81cb48c686cf5376800
However, while
read.table
properly handles reading the content withsep="\t"
,data.table::fread
produces adata.table
with wrongly-typed columns, some of them coerced tocharacter
due to white-space characters0x20
while they truly arenumeric
orinteger
when such white-spaces are properly trimmed.The results produced by
data.table::fread
is as follows:Even when
sep="\t"
is explicitly specified, things remain the same:The white-spaces are represented by
20
in hex raw:The text was updated successfully, but these errors were encountered: