Dplyr: order_by() could have an error hint when confused with arrange()

Created on 13 Feb 2018  Â·  6Comments  Â·  Source: tidyverse/dplyr

For those of us who sometimes have SQL on the brain...

> df <- df %>% order_by(value)
Error: `call` must be a function call, not a symbol
> df <- df %>% order_by(-value)
Error: Can't use matrix or array for column indexing
> df <- df %>% arrange(-value)

e.g. Did you mean to use arrange()?

feature funs

Most helpful comment

I just stumbled upon this while trying to figure out why order_by is "not working for me today"... 😆

All 6 comments

I just stumbled upon this while trying to figure out why order_by is "not working for me today"... 😆

Similarly, select() could have an error hint when confused with filter(). (Students often mix those two up, and so too does my jetlagged brain.)

This is a great suggestion ('did you mean to use arrange()?'), why yes, I did but I scrmalbed the R/SQL in my head.

AmeliaMN - I'd vote for select() being confused with pull().

@AmeliaMN @baderstine I can't see any easy way to disambiguate select(), filter(), or pull() so I've hidden your comments. If you can think of a good approach, please feel free to open new issues.

This would be relatively simple to implement — order_by() just needs to check if call is a symbol, and if so, offer a hint about arrange().

stumbled upon this after a long break from the tidyverse. Hint about 'arrange()' in the error message would be a nice touch.

Was this page helpful?
0 / 5 - 0 ratings