Closed
Description
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