New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: fct_as_factor()/as_factor() #39

Closed
MilesMcBain opened this Issue Sep 12, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@MilesMcBain
Copy link

MilesMcBain commented Sep 12, 2016

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().

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Sep 15, 2016

Maybe just as_factor() ?

@MilesMcBain

This comment has been minimized.

Copy link

MilesMcBain commented Sep 16, 2016

Yep, autocomplete friendly. Sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment