The result of A and B merge inherits B's custom classes which does not seem intuitive to me at all. Example: A=data.table(x=c(1,2,3),y=c(4,5,6)) B=data.table(x=c(1),w=c(5)) class(B) <- c("custom","data.table","data.frame") C=merge(A,B,by=c('x')) class(C) Expecting: "data.table" "data.frame" Getting: "custom" "data.table" "data.frame"