No subject


Mon Jun 6 11:45:04 CEST 2011


dt[J(1,3)]

is significantly faster 

dt[y==1 & z==3]


and I could do

dt[J(1)]

instead of 

dt[y==1]

but is there any way to do 

dt[z==3]

faster?  I want to do something like

df[J( ,3)]

but I know that doesn't make sense. Is it because z is not the primary key 
that I can't seem to figure out how to use J to do this? Since it isn't 
sorted on z anyway I doubt I can get a speed up right?

------=_Part_83_8935011.1310512907328
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8"><d=
iv class=3D"GBQ1X2BDHL"><span style=3D"border-collapse: collapse; "><font c=
lass=3D"Apple-style-span" color=3D"#000000">Hi all,<div><br></div><div>I'm =
really new to data.table and something really simple has me stumped.</div><=
div><br></div><div>Lets say I have the following (but much bigger so timing=
 matters)</div><div><br></div><div>dt =3D data.table(x=3D1:100,y=3D1:2,z=3D=
1:<wbr>4,key=3D"y,z")</div><div><br></div><div>From the documentation, I un=
derstand that</div><div><br></div><div>dt[J(1,3)]</div><div><br></div><div>=
is significantly faster&nbsp;</div><div><br></div><div>dt[y=3D=3D1 &amp; z=
=3D=3D3]</div><div><br></div><div><br></div><div>and I could do</div><div><=
br></div><div>dt[J(1)]</div><div><br></div><div>instead of&nbsp;</div><div>=
<br></div><div>dt[y=3D=3D1]</div><div><br></div><div>but is there any way t=
o do&nbsp;</div><div><br></div><div>dt[z=3D=3D3]</div><div><br></div></font=
></span></div><span style=3D"border-collapse: collapse; "><div>faster? &nbs=
p;I want to do something like</div><div><br></div><div>df[J( ,3)]</div><div=
><br></div><div>but I know that doesn't make sense. Is it because z is not =
the primary key that I can't seem to figure out how to use J to do this? Si=
nce it isn't sorted on z anyway I doubt I can get a speed up right?</div></=
span>
------=_Part_83_8935011.1310512907328--

------=_Part_82_22835992.1310512907328--


More information about the datatable-help mailing list