If your set of common keys / indices completely overlaps, then ...
Reduce(`&`, user$user.id %in% some.data$user.id)
... returns TRUE, and they, as you said, are sorted, and there are no duplicate keys , then your join problem comes down to adding columns to data.frame. Something in the lines along ...
library(log4r) t1 <- system.time(z <- merge(user, some.data, by='user.id')) info(my.logger, paste('Elapsed time with merge():', t1['elapsed'])) t2 <- Sys.time() r <- data.frame(user.id=user$user.id, V1.x=user$V1, V2.x=user$V2) r[,names(some.data)] <- some.data[,names(some.data) t3 <- Sys.time() info(my.logger, paste('Elapsed time without:', t3-t2))
If the above assumptions are not fulfilled, then he gets a slightly more erratic union of joins of both key sets and the translation function, scroll NA), but the only assumption of merging and overlapping gives you a long way to go.
Note also that the seconds approach time is biased, since it calls Sys.time () twice, unlike the merge () time, which calls system.time () and only once. (Sorry my lame use of SO markup)
source share