[R] Why is merge sorting even when sort = F?

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Wed Mar 8 17:07:27 CET 2017


Hello!
I have a vector 'grades' and a data frame 'info':

grades2 <- data.frame(grade = c(1,2,2,3,1))
info <- data.frame(
  grade = 3:1,
  desc = c("Excellent", "Good", "Poor"),
  fail = c(F, F, T)
)

I want to get the info for all grades I have in info:

This solution resorts everything in the order of column 'grade':
merge(grades2, info, by = "grade", all.x = T, all.y = F)

Could you please explain why this solution also resorts - despite sort = FALSE?
merge(grades2, info, by = "grade", all.x = T, all.y = F, sort = FALSE)

Thanks a lot!
-- 
Dimitri Liakhovitski



More information about the R-help mailing list