R data.table : data.tables 목록을 병합하려면 어떻게해야합니까? [복제]

Dec 11 2020

data.tables의 긴 목록이 있습니다. 단일 data.table에서 모두 병합 (내부 조인)하고 싶습니다.

dplyrpurrr나는 할 수있다 :

dt1 <- data.table(cbind(letters[1:10], 1:10))
dt2 <- data.table(cbind(letters[3:12], 3:12))
dt3 <- data.table(cbind(letters[5:15], 5:15))

dtl <- list(dt1, dt2, dt3)

library(dplyr)
library(purrr)
merged <- dtl %>% reduce(inner_join, by='V1')

data.table로 어떻게 할 수 있습니까?

답변

2 akrun Dec 11 2020 at 01:11

조인을 사용할 수 있습니다 on

library(data.table)
na.omit(Reduce(function(x, y) x[y, on = .(V1)], dtl))