<table cellspacing="0" cellpadding="0" border="0"><tr><td valign="top"><div id='yahoo__compose_area' style="background-color:white; display:block; font-family:HelveticaNeue-Regular,Helvetica;"><div>Let me illustrate my question with an example:</div><div><br></div><div>DT<-data.table(A=c("a","b"),B=c(1,2))</div><div>setkey(DT,A)</div><div><br></div><div>DT["a"]</div><div><br></div><div>The above works without error; however:</div><div><br></div><div>DT<-data.table(A=as.Date(c("2001-01-01","2002-01-01")),B=c(1,2))</div><div>setkey(DT,A)</div><div><br></div><div>DT[as.Date("2001-01-01")] gives an error:</div><div><br></div><div>"i has not evaluated to logical,integer or double"</div><div><br></div><div>Why does one give error while the other doesnt please?</div><div><br></div><br><br><br><a href="https://yho.com/footer0">Sent from Yahoo Mail for iPhone</a></div><div id='yahoo__original_message'></div></html></td></tr></table>