dplyr arrange by reverse alphabetical order

Viewed 34160

I'm curious why the arrange function won't will work for alphabetical order but not reverse alphabetical order.

df <- data.frame(string = as.character(c("b", "a", "c")), stringsAsFactors = F) 

df %>% arrange(string) #works

df %>% arrange(-string) #does not work

Am I just using the completely wrong method for what I'm trying to accomplish?

1 Answers

From the ?arrange help page, use desc()

df %>% arrange(desc(string))
Related