<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I see at <a href="https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1482&group_id=240&atid=978">
https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1482&group_id=240&atid=978</a> that POSIXct values are supported as key. But I’m unsure how to efficiently query them. Here are my attempts:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> library(lubridate)<o:p></o:p></p>
<p class="MsoNormal">> n <- now()<o:p></o:p></p>
<p class="MsoNormal">> d <- data.table(t=n+days(1:10), val=runif(10), key='t')<o:p></o:p></p>
<p class="MsoNormal">> d[n+days(1)]<o:p></o:p></p>
<p class="MsoNormal">Error in `[.data.table`(d, n + days(1)) : <o:p></o:p></p>
<p class="MsoNormal"> i has not evaluated to logical, integer or double<o:p></o:p></p>
<p class="MsoNormal">> d[n+days(1),]<o:p></o:p></p>
<p class="MsoNormal">Error in `[.data.table`(d, n + days(1), ) : <o:p></o:p></p>
<p class="MsoNormal"> i has not evaluated to logical, integer or double<o:p></o:p></p>
<p class="MsoNormal">> d[list(n+days(1)),]<o:p></o:p></p>
<p class="MsoNormal">Error in `[.data.table`(d, list(n + days(1)), ) : <o:p></o:p></p>
<p class="MsoNormal"> typeof x.t (integer) != typeof i.V1 (double)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I can query using a boolean, but I assume this is skipping the index on 't'?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> d[t==n+days(1),]<o:p></o:p></p>
<p class="MsoNormal"> t val<o:p></o:p></p>
<p class="MsoNormal">[1,] 2012-09-22 21:06:52 0.2550606<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">--<o:p></o:p></p>
<p class="MsoNormal">Ken Williams, Senior Research Scientist<o:p></o:p></p>
<p class="MsoNormal"><b><i><span style="color:#365F91">Wind</span></i></b><b><i><span style="color:#76923C">Logics</span></i></b><b><i><o:p></o:p></i></b></p>
<p class="MsoNormal">http://windlogics.com<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<hr>
<font face="Verdana" color="Blue" size="2">CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any
kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.<br>
</font>
</body>
</html>