forcats - sort levels alphabetically

In forcats we can sort levels inorder, infreq, inseq. But is there function to sort alphabetically?

Sometimes I just use e.g. case_when to define some groups and I give them prefixes a,b,c,... and to have it in order i need to use base as.factor. Or if I use date/time to char conversion (e.g %Y-%m).

I would expect something like fct_inalpha (but with better name).

If not should it be?

Just use factor. It does exactly what you want it to do, and forcats would just add a pointless level of indirection.

Not completly. As is stated in help to forcats there are problems with locale and sorting. So dedicated function with default C collation could be helpful.

Every collation/character set will sort this in the assumed order.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.