I have the following data table.
ts,id 1,a 2,a 3,a 4,a 5,a 6,a 7,a 1,b 2,b 3,b 4,b
I want to multiply this data table in two. The criteria are to have approximately the first half for each group (in this case, the "id" column) in one data table, and the rest in another data table. So the expected result are two data.tables as follows
ts,id 1,a 2,a 3,a 4,a 1,b 2,b
and
ts,id 5,a 6,a 7,a 3,b 4,b
I tried the following:
z1 = x[,.SD[.I < .N/2,],by=dev] z1
and received only the following
id ts a 1 a 2 a 3
Somehow .I inside .SD does not work as it seems to me. Any help appreciated. Thanks in advance.