dplyr arrange by reverse alphabetical order [dupli

2020-04-02 08:24发布

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?

标签: r dplyr
1条回答
地球回转人心会变
2楼-- · 2020-04-02 09:04

From the ?arrange help page, use desc()

df %>% arrange(desc(string))
查看更多
登录 后发表回答