How to sort a data.table using vector of multiple columns
问题 I am pretty new to R and trying to build a function to compare two data set, in order to do that I need to sort data table on multiple columns.I am sure there will be some help somewhere but I am not sure how to search for it. This is my approach so far: DT = data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6), v=1:9) #column vector keycol <- c("x","y") DT[order(keycol)] x y v 1: b 1 1 2: b 3 2 Somehow It displays just 2 rows and removes other records.But if I do this: > DT[order(x,y)] x y v