更新:从提交 966 开始,这现在在R-Forge的 v1.8.11中实现。来自NEWS:
fread
'sdrop
和select
in已实现NULL
。colClasses
按名称或编号删除或选择列。请参阅 中的示例?fread
。
中的示例?fread
是:
data = "A,B,C,D\n1,3,5,7\n2,4,6,8\n"
# colClasses
fread(data, colClasses=c(B="character",C="character",D="character"))
fread(data, colClasses=list(character=c("B","C","D"))) # saves typing
fread(data, colClasses=list(character=2:4)) # same using column numbers
# drop
fread(data, colClasses=c("B"="NULL","C"="NULL")) # as read.csv
fread(data, colClasses=list(NULL=c("B","C"))) # same
fread(data, drop=c("B","C")) # same but less typing, easier to read
fread(data, drop=2:3) # same using column numbers
# select
# (in read.csv you need to work out which to drop)
fread(data, select=c("A","D")) # less typing, easier to read
fread(data, select=c(1,4)) # same using column numbers