R data.table fread using named colClasses without header (e.g. no col.names?)
data.table, fread, r
Solution
Add the names in the command line:
fread('echo "id,name,gender"; grep Male students.csv', colClasses = c(id='numeric'))
Problem
update (June 2016) col.names was added on data.table 1.9.6 so issue is over and everyone super happy :) I think I can now convert all my read.csv calls to fread calls without worries of destruction original question using data.table 1.9.4 I'm importing read.csv calls to fread due to HUGE performance improvements we've noticed. Most issues I can handle but I've reached a point where I'm clueless and wonder if anyone has an elegent solution. My problem is that I have named colClasses but the input has no header (it's a grep function), here's a silly example to make sense: ``` males.students <- read.csv(pipe("grep Male students.csv"), col.names=c("id", "name", "gender"), colClasses=(id="numeric")) ``` now in fread I still want the named colClasses but I have no col names so just using ``` males.students <- fread("grep Male students.csv"), colClasses=(id="numeric")) ``` fails with Column name 'id' in colClasses[[1]] not found How can I fix that? are there plans to add col.names?