I'm trying to read a .csv file that looks like this with quotes in every cell:
"a","b"
"1","hello"
"2","hello, test"
Using read.csv() it works fine with column "a" of type integer. With data.table::fread() column "a" is of type character, though.
x <- fread("\"a\",\"b\"\n\"1\",\"hello\"\n\"2\",\"hello, test\"")
summary(x)
a b
Length:2 Length:2
Class :character Class :character
Mode :character Mode :character
Is there a way to tell fread to determine the column types in fully quoted .csv files?
colClasses
-parameter. See?fread
. – Jaapx[, names(x) := lapply(.SD, type.convert)]
to convert after the fact. Maybe that step should be added as an option to fread... – Frank