this looks quite beneficial.<br><br>I find myself doing the following a lot<br><br>dt$Date= as.integer(format(dt$Date, &quot;%Y%m%d&quot;))<br><br>So this should take care of this problem.<br><br>I&#39;ll see where I can use this and try to test it out,<br>
Rob<br><br><div class="gmail_quote">On Mon, Apr 12, 2010 at 4:08 PM, Short, Tom <span dir="ltr">&lt;<a href="mailto:TShort@epri.com">TShort@epri.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
See enclosed for a draft of classes that implement dates and times with<br>
integer storage. The IDate class is a simple wrapper around the Date<br>
class that tries to keep an integer storage format. The ITime class, the<br>
time of day, is stored as the number of seconds in a day.<br>
<br>
Because IDate and ITime are stored as integers with ranges less than<br>
100,000, data.table indexing and sorting is fast. Also included are<br>
conversions to and from POSIXct and chron formats.<br>
<br>
Comments and tests are welcome.<br>
<br>
Examples:<br>
<br>
&gt;     (t &lt;- as.ITime(&quot;10:45:04&quot;))<br>
[1] &quot;10:45:04&quot;<br>
&gt;     (d &lt;- as.IDate(&quot;2001-01-01&quot;))<br>
[1] &quot;2001-01-01&quot;<br>
&gt;<br>
&gt;     datetime &lt;- seq(as.POSIXct(&quot;2001-01-01&quot;),<br>
+                     as.POSIXct(&quot;2001-01-03&quot;), by = &quot;5 hour&quot;)<br>
&gt;<br>
&gt;     (a &lt;- data.table(IDateTime(datetime), a = rep(1:2, 5),<br>
+                      key = &quot;a,date,time&quot;))<br>
            date     time a<br>
 [1,] 2001-01-01 00:00:00 1<br>
 [2,] 2001-01-01 10:00:00 1<br>
 [3,] 2001-01-02 06:00:00 1<br>
 [4,] 2001-01-02 16:00:00 1<br>
 [5,] 2001-01-02 20:00:00 1<br>
 [6,] 2001-01-01 05:00:00 2<br>
 [7,] 2001-01-01 15:00:00 2<br>
 [8,] 2001-01-02 01:00:00 2<br>
 [9,] 2001-01-02 11:00:00 2<br>
[10,] 2001-01-03 21:00:00 2<br>
&gt;<br>
&gt;     a[, mean(a), by = &quot;date&quot;]<br>
           date  V1<br>
[1,] 2001-01-01 1.5<br>
[2,] 2001-01-02 1.4<br>
[3,] 2001-01-03 2.0<br>
&gt;<br>
&gt;     as.POSIXct(af$date, af$time)<br>
[1] &quot;2001-01-01 00:00:00 EST&quot; &quot;2001-01-01 18:00:00 EST&quot;<br>
[3] &quot;2001-01-02 12:00:00 EST&quot; &quot;2001-01-01 06:00:00 EST&quot;<br>
[5] &quot;2001-01-02 00:00:00 EST&quot; &quot;2001-01-02 18:00:00 EST&quot;<br>
[7] &quot;2001-01-01 12:00:00 EST&quot; &quot;2001-01-02 06:00:00 EST&quot;<br>
[9] &quot;2001-01-03 00:00:00 EST&quot;<br>
<br>
- Tom<br>
<font color="#888888"><br>
Tom Short<br>
Electric Power Research Institute (EPRI)<br>
<br>
<br>
</font><br>_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
<br></blockquote></div><br>