require(data.table)
# Loading required package: data.table
# data.table 1.11.5 IN DEVELOPMENT built 2018-06-02 00:09:06 UTC; travis Latest news: http://r-datatable.com
str <- "x1,x2,x3,x4,x5\n1,2,1.5,T,cc\n3,4,2.5,F,ff"
# Read correctly
fread(str)
# x1 x2 x3 x4 x5
# 1: 1 2 1.5 T cc
# 2: 3 4 2.5 F ff
# col x4 is wrong
fread(str, colClasses=c("integer", "numeric", "numeric", "integer", "character"))
# x1 x2 x3 x4 x5
# 1: 1 2 1.5 cc cc
# 2: 3 4 2.5 ff ff
# col x4 is wrong here as well
fread(str, colClasses=c("integer", "numeric", "numeric", "logical", "character"))
# x1 x2 x3 x4 x5
# 1: 1 2 1.5 cc cc
# 2: 3 4 2.5 ff ff
# correct if colClasses for x4 is 'character' type
fread(str, colClasses=c("integer", "numeric", "numeric", "character", "character"))
# x1 x2 x3 x4 x5
# 1: 1 2 1.5 T cc
# 2: 3 4 2.5 F ff