You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I am trying to create a data.table with lagged variables by group id. Certain id's have only 1 row in the data.table in that case the shift operator for lag gives error but the lead operator works fine. Here is an example
# All items in j=list(...) should be atomic vectors or lists. If you are trying something like # `j=list(.SD,newcol=mean(colA))` then use `:=` by group instead (much quicker), or # `cbind` or `merge` afterwards.
But if I try the same thing with lead instead, it works fine
Hi I am trying to create a data.table with lagged variables by group id. Certain id's have only 1 row in the data.table in that case the shift operator for lag gives error but the lead operator works fine. Here is an example
This gives me the following error
But if I try the same thing with lead instead, it works fine
It also seem to work fine if the data.table has more than 1 row e.g. you can try the following with 2 rows which works fine
I am using data.table version 1.9.5 on a linux machine with R version 3.1.0. Any help would be much appreciated.
Thanks,
Ashin
The text was updated successfully, but these errors were encountered: