[datatable-help] Skipping some Vi names

Joseph Voelkel jgvcqa at rit.edu
Thu Jul 14 22:43:36 CEST 2011


Continuing with the example below, here is another problem: names() returns NA's for all Vi names except V1.

> (dt2<-dt[,list("sum(A1),sum(A2),sum(A3)"),by="x,y"])
     x y V1 V4 V5
[1,] 1 1  1  7 13
[2,] 1 2  4 10 16
[3,] 2 1  2  8 14
[4,] 2 3  5 11 17
[5,] 3 2  3  9 15
[6,] 3 3  6 12 18
> names(dt2)
[1] "x"  "y"  "V1" NA   NA


From: Joseph Voelkel
Sent: Thursday, July 14, 2011 4:36 PM
To: datatable-help at lists.r-forge.r-project.org
Subject: Skipping some Vi names

I don't use data.table too much (though I probably should use it more...).

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.

> 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")
> dt[,list("sum(A1),sum(A2),sum(A3)"),by="x"]
     x V1 V3 V4
[1,] 1  5 17 29
[2,] 2  7 19 31
[3,] 3  9 21 33
> key(dt)<-c("x","y")
> dt[,list("sum(A1),sum(A2),sum(A3)"),by="x,y"]
     x y V1 V4 V5
[1,] 1 1  1  7 13
[2,] 1 2  4 10 16
[3,] 2 1  2  8 14
[4,] 2 3  5 11 17
[5,] 3 2  3  9 15
[6,] 3 3  6 12 18



Joseph G. Voelkel, Ph.D.
Professor, Center for Quality and Applied Statistics
Kate Gleason College of Engineering
Rochester Institute of Technology
V 585-475-2231
F 585-475-5959
joseph.voelkel at rit.edu

CONFIDENTIALITY NOTE: 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20110714/ee3e592c/attachment.htm>


More information about the datatable-help mailing list