How to find nearest highest value when join data.table
问题 I have the following 2 data tables: DT1 <- data.table(A = c(100,50,10), B = c("Good","Ok","Bad")) DT1 A B 1: 100 Good 2: 50 Ok 3: 10 Bad and DT2 <- data.table(A = c(99,34,5,"",24,86)) DT2 A 1: 99 2: 34 3: 5 4: 5: 24 6: 86 What I would like to return when joining DT1 and DT2 is DT2 A B 1: 99 Good 2: 34 Ok 3: 5 Bad 4: NA 5: 24 Ok 6: 86 Good The "roll" option in data.table is only for "nearest" match so it doesnt work in my case. Is there any way I can do such lookup with data.table? 回答1: The