2

I have two sets of names that are ordered A-Z. I'm using anti_join to filter out whatever is present in the 2nd set. Example:

library(dplyr)
t1 <- data.frame(Name = state.name, Abbr = state.abb)
t2 <- data.frame(Abbr = state.abb[50])
t3 <- anti_join(t1, t2, by = "Abbr")

The result is in reverse sort order. I tried adding ascending/descending=TRUE but nothing. Is there a way to keep the sort order intact, without adding another line, that I am missing?

armipunk
  • 458
  • 2
  • 13
  • It's annoying (and maybe worth an issue on GitHub if there isn't one), but honestly you shouldn't count on the order of a join returning a certain way. Just use `arrange`. – alistaire Feb 18 '17 at 03:42
  • Thanks. Pretty new to R, and coding in general, so good to know it's not just me being stupid and missing the obvious. – armipunk Feb 19 '17 at 04:22

0 Answers0