Skip to content

Instantly share code, notes, and snippets.

View jinseob2kim's full-sized avatar

Jinseob Kim jinseob2kim

View GitHub Profile
@pimentel
pimentel / data.table_roll-nearest.R
Last active March 16, 2022 07:06
examples of rolling join in data.table
DT1 <- data.table(x = 1:5)
DT2 <- data.table(y = (1:5) + 0.01)
setkey(DT1, x)
setkey(DT2, y)
# the following does not maintain both columns
DT1[DT2, roll = 'nearest']
# x
# 1: 1
# 2: 2