What about
dt[,unique(names(dt)),with=FALSE]
? From ?data.table :
j: single column name, single instance of column names, 'List () expressions of column names, expressions, or a function call that evaluates a' list (including 'Data.frame and' data.table, which are also lists, or (when 'with = FALSE) is the vector of names or positions to select.
This picks the first occurrence of each name (I'm not sure how you want to deal with this).
As @DavidArenburg points out in the comments above, you can use check.names=TRUE in data.table() (however, I don't see the check.names option in fread() - maybe I missed something).
Ben bolker
source share