<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:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 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.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.gd40030cnr
        {mso-style-name:gd40030cnr;}
span.gd40030cbr
        {mso-style-name:gd40030cbr;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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><span style='color:#1F497D'>Continuing with the example below, here is another problem: names() returns NA’s for all Vi names except V1.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>> (dt2<-dt[,list("sum(A1),sum(A2),sum(A3)"),by="x,y"])<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'> 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 1 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 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 2 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 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 3 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 6 12 18<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>> names(dt2)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'>[1] "x" "y" "V1" NA NA <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Joseph Voelkel <br><b>Sent:</b> Thursday, July 14, 2011 4:36 PM<br><b>To:</b> datatable-help@lists.r-forge.r-project.org<br><b>Subject:</b> Skipping some Vi names<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I don’t use data.table too much (though I probably should use it more…). <o:p></o:p></p><p class=MsoNormal><o:p> </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 (“in the background”) 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’s annoying. (I have over 40 Vi’s and it’d be good to have them numbered more rationally.) Thanks.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>> dt<-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="x")<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>> dt[,list("sum(A1),sum(A2),sum(A3)"),by="x"]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'> 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 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 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 9 21 33<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>> key(dt)<-c("x","y")<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:blue'>> dt[,list("sum(A1),sum(A2),sum(A3)"),by="x,y"]<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Console";color:black'> 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 1 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 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 2 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 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 3 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 6 12 18<o:p></o:p></span></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>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> </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> </o:p></p></div></body></html>