Skip to content

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

@MilesMcBain

Description

@MilesMcBain

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions