Using fread () from data.table breaks the R session

I'm working on a project for MOOC and messing around with the package data.table

in RStudio. Using the function fread()

for initial work with data files:

fread("UCI HAR Dataset/features.txt")->features
fread("UCI HAR Dataset/test/y_test.txt")->ytest

      

However, when I tried to run the following line of code, I got a popup that said "R Session Aborted: R encountered a fatal error. The session was terminated."

fread("UCI HAR Dataset/test/X_test.txt")->xtest

      

I do not understand what the problem is. I have checked the filenames and paths to make sure I have spelled and captioned everything correctly and everything is checked. The equivalent code using read.table () works fine and does not cause R interrupts. I also tried to rename the file to "x_test.txt" but the same problem occurred.

According to this ?fread

, only the function will only work with "regular delimited files". As far as I can tell, the file is a "regular delimited file" since all rows have the same number of columns. There are no cells containing "NA" when I use read.table; I checked with anyNA()

. Is there a quick way to determine if a file is "regularly" restricted or not? Is there something else in the original file that might be causing the problem?


UPDATE

After further research and searching for the reported issues listed on the developer github, I think my problem is that there are two spaces at the beginning of each line, which is what it says here . I'm not sure why R interrupted instead of warning me. However, the latest version of data.table (1.9.5) does not cause the session to be terminated under the same conditions.

+3


source to share


1 answer


While I do believe you should have contacted the package manager in the first place in any situation where the R session was interrupted (and this was not due to your bias from the C code), I can suggest a strategy for your last request. which is not very specific to fread

, but I found useful with regular reads (). I'm going to assume it is a comma delimited file, but if it is; space is separated, you can change sep=","

to sep=""

.

filcnts <- count.fields("UCI HAR Dataset/test/X_test.txt", sep=",")
table(filcnts)

      



It should be a table with individual elements. If not, try to change parameters such as quote

, sep

, blank.lines.skip

orcomment.char

+2


source







All Articles