[ACCEPTED]-rolling joins data.table in R-data.table
That quote from the documentation appears 31 to be from FAQ 1.12 What is the difference between X[Y] and merge(X,Y). Did you find the 30 following in
?data.table and does it help?
rollApplies 29 to the last join column, generally a date 28 but can be any ordered variable, irregular 27 and including gaps. If roll=TRUE and i's row 26 matches to all but the last x join column, and 25 its value in the last i join column falls 24 in a gap (including after the last observation 23 in x for that group), then the prevailing 22 value in x is rolled forward. This operation 21 is particularly fast using a modified binary 20 search. The operation is also known as last 19 observation carried forward (LOCF). Usually, there 18 should be no duplicates in x's key, the last 17 key column is a date (or time, or datetime) and 16 all the columns of x's key are joined 15 to. A common idiom is to select a contemporaneous 14 regular time series (dts) across a set of 13 identifiers (ids): DT[CJ(ids,dts),roll=TRUE] where 12 DT has a 2-column key (id,date) and CJ 11 stands for cross join.
rolltolastLike roll but the 10 data is not rolled forward past the last observation 9 within each group defined by the join columns. The 8 value of i must fall in a gap in x but 7 not after the end of the data, for that 6 group defined by all but the last join column. roll 5 and rolltolast may not both be TRUE.
In 4 terms of left/right analogies to SQL joins, I 3 prefer to think about that in the context 2 of FAQ 2.14 Can you explain further why data.table is inspired by A[B] syntax in base. That's quite a long answer 1 so I won't paste it here.
More Related questions