Skip to content

complete() turns ordered factors into unordered factors #165

Description

@phirsch

If complete() is applied to a column that is an ordered factor, the result is no longer an ordered factor, but a plain factor instead (in tidyr_0.4.1):

> df = data_frame(a = as.ordered(1:2), b = as.ordered(1:2))
> str(df)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   2 obs. of  2 variables:
 $ a: Ord.factor w/ 2 levels "1"<"2": 1 2
 $ b: Ord.factor w/ 2 levels "1"<"2": 1 2
> df %>% complete(a, b) %>% str()
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   4 obs. of  2 variables:
 $ a: Factor w/ 2 levels "1","2": 1 1 2 2
 $ b: Factor w/ 2 levels "1","2": 1 2 1 2
> 

Activity

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

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