The base as.factor() returns levels in a platform/locale dependent manner due to sorting the levels. See: Why does as.factor() on unicode strings return different results for every operating system?.
This can get nasty in the context of reproducible RMarkdown reports, dashboards etc. I can provide entertaining anecdotal evidence of how this can and did go wrong, if you can't see what I mean.
As such, I propose a new version of as.factor() be included in forcats that returns a platform independent ordering of factor levels. It'll become the standard factor conversion for people who care about platform independence and reproducibility (everyone?). The choice of ordering I'm not fussy about, although I reckon the most obvious is as per fct_inorder().
The base
as.factor()returns levels in a platform/locale dependent manner due to sorting the levels. See: Why does as.factor() on unicode strings return different results for every operating system?.This can get nasty in the context of reproducible RMarkdown reports, dashboards etc. I can provide entertaining anecdotal evidence of how this can and did go wrong, if you can't see what I mean.
As such, I propose a new version of
as.factor()be included inforcatsthat returns a platform independent ordering of factor levels. It'll become the standard factor conversion for people who care about platform independence and reproducibility (everyone?). The choice of ordering I'm not fussy about, although I reckon the most obvious is as perfct_inorder().