 <p>One data.table way of indexing a column by number would be to convert to a column name , convert to an R symbol, and evaluate:</p> <pre><code>mydata[ , eval( as.symbol( names(mydata)[1] ) )] [1] "ID123" "ID22" "AAA" &gt; grep("^ID", mydata[,eval(as.symbol(names(mydata)[1]))]) [1] 1 2 </code></pre> <p>But this is not really an approved path to success because of the DT FAQ #1 as well as the fact that row numbers are not considered as valid targets. The philosophy (as I understand it) is that row numbers are accidental and you should be storing your records with unique identifiers.</p>