<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 12 (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;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 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;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.gd40030cnr
        {mso-style-name:gd40030cnr;}
span.gd40030cbr
        {mso-style-name:gd40030cbr;}
.MsoChpDefault
        {mso-style-type:export-only;}
@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>I don&#8217;t use data.table too much (though I probably should use it more&#8230;). <o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I was surprised at the results below. It appears that the name V1 gets assigned to the first result, but then the keys (&#8220;in the background&#8221;) are assigned the next set of Vi names, creating a gap in the names depending on the number of keys. I would like to see the Vi names appear in their natural, sequential, order. Not a show stopper, but it&#8217;s annoying. (I have over 40 Vi&#8217;s and it&#8217;d be good to have them numbered more rationally.) Thanks.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>&gt; dt&lt;-data.table(x=c(1,2,3,1,2,3),y=c(1,1,2,2,3,3),A1=1:6,A2=7:12,A3=13:18,key=&quot;x&quot;)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>&gt; dt[,list(&quot;sum(A1),sum(A2),sum(A3)&quot;),by=&quot;x&quot;]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>&nbsp;&nbsp;&nbsp;&nbsp; x V1 V3 V4<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[1,] 1&nbsp; 5 17 29<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[2,] 2&nbsp; 7 19 31<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[3,] 3&nbsp; 9 21 33<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>&gt; key(dt)&lt;-c(&quot;x&quot;,&quot;y&quot;)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>&gt; dt[,list(&quot;sum(A1),sum(A2),sum(A3)&quot;),by=&quot;x,y&quot;]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>&nbsp;&nbsp;&nbsp;&nbsp; x y V1 V4 V5<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[1,] 1 1&nbsp; 1&nbsp; 7 13<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[2,] 1 2&nbsp; 4 10 16<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[3,] 2 1&nbsp; 2&nbsp; 8 14<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[4,] 2 3&nbsp; 5 11 17<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[5,] 3 2&nbsp; 3&nbsp; 9 15<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[6,] 3 3&nbsp; 6 12 18<o:p></o:p></span></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Joseph G. Voelkel, Ph.D.<o:p></o:p></p><p class=MsoNormal>Professor, Center for Quality and Applied Statistics<o:p></o:p></p><p class=MsoNormal>Kate Gleason College of Engineering<o:p></o:p></p><p class=MsoNormal>Rochester Institute of Technology<o:p></o:p></p><p class=MsoNormal>V 585-475-2231<o:p></o:p></p><p class=MsoNormal>F 585-475-5959<o:p></o:p></p><p class=MsoNormal>joseph.voelkel@rit.edu<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><b><span style='font-size:10.0pt'>CONFIDENTIALITY NOTE</span></b><span style='font-size:10.0pt'>: The information transmitted, including attachments, is intended only for the person(s) or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and destroy any copies of this information.</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>