fread

How to read when delimiter is space and missing values are blank?

夙愿已清 提交于 2021-01-24 06:54:56
问题 I have a space delimited file and some columns are blank, so we end up having multiple spaces, and fread fails with error. But read.table works fine. See example: library(data.table) # R version 3.4.2 (2017-09-28) # data.table_1.10.4-3 fread("A B C D 1 2 3 4 5 6 7", sep = " ", header = TRUE) Error in fread("A B C D\n1 2 3\n4 5 6 7") : Expected sep (' ') but new line, EOF (or other non printing character) ends field 2 when detecting types from point 0: 1 2 3 read.table(text ="A B C D 1 2 3 4 5