Skip to content

disctint() doesn't respect the order of variables provided #3195

Description

@fmichonneau

The output of distinct() doesn't follow the order of the columns provided by the user but uses the order of the original data:

> starwars %>% distinct(hair_color, skin_color)
# A tibble: 50 x 2
      hair_color  skin_color
           <chr>       <chr>
 1         blond        fair
 2          <NA>        gold
 3          <NA> white, blue
 4          none       white
 5         brown       light
 6   brown, grey       light
 7          <NA>  white, red
 8         black       light
 9 auburn, white        fair
10  auburn, grey        fair
# ... with 40 more rows
> starwars %>% distinct(skin_color, hair_color)
# A tibble: 50 x 2
      hair_color  skin_color
           <chr>       <chr>
 1         blond        fair
 2          <NA>        gold
 3          <NA> white, blue
 4          none       white
 5         brown       light
 6   brown, grey       light
 7          <NA>  white, red
 8         black       light
 9 auburn, white        fair
10  auburn, grey        fair
# ... with 40 more rows

Activity

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

Metadata

Metadata

Labels

featurea feature request or enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions