It's always been a bit confusing to me that .I is "global" in the sense that it doesn't change with by, while .N is "local" in the sense that it does.
I understand (some of) the advantages of this arrangement, but I think there are ample situations for using a local .I (see, e.g. 1, 2, 3, etc.) or a global .N (e.g., 1).
I'm not sure how easy this is to build into the source code, but having .i and .n be "local" while .I and .N are "global" seems like an intuitive alternative. On the other hand, it could be painful to switch the behavior of .N given that it's so ubiquitous in data.table code.
Throwing a hat in the ring for .SD and .sd as well, since I've been tempted a few times to try .SD with the intention of getting the full table within by, specifically here.
It's always been a bit confusing to me that
.Iis "global" in the sense that it doesn't change withby, while.Nis "local" in the sense that it does.I understand (some of) the advantages of this arrangement, but I think there are ample situations for using a local
.I(see, e.g. 1, 2, 3, etc.) or a global.N(e.g., 1).I'm not sure how easy this is to build into the source code, but having
.iand.nbe "local" while.Iand.Nare "global" seems like an intuitive alternative. On the other hand, it could be painful to switch the behavior of.Ngiven that it's so ubiquitous indata.tablecode.Throwing a hat in the ring for
.SDand.sdas well, since I've been tempted a few times to try.SDwith the intention of getting the full table withinby, specifically here.