I'm still confused by what exactly you're looking for. Because you've grouped by two variables, the grouping for the second will occur within the grouping for the first (which is why you see the order-swap for some of your desired output, since the WifiMac
variables are different:
library(dplyr)
testdat <- tibble::tribble(
~Auto.ID, ~WifiMac, ~GroupID.x, ~VillageId, ~Duplicate, ~`Duplicate.(groups)`, ~Desirable.Result,
1L, "48:88:ca:4f:74:37", "GRP18450", 1403L, "Low", 1L, 0L,
2L, "48:88:ca:4f:74:37", "GRP18457", 1403L, "Low", 1L, 0L,
4L, "48:88:ca:4f:a6:a4", "GRP12782", 752L, "Low", 1L, 2L,
3L, "48:88:ca:4f:a6:a4", "GRP12795", 752L, "Medium", 2L, 1L,
5L, "48:88:ca:4f:a6:ef", "GRP12788", 752L, "Low", 1L, 2L,
6L, "48:88:ca:4f:a6:ef", "GRP12789", 752L, "Medium", 2L, 1L,
7L, "48:88:ca:4f:a7:00", "GRP12698", 757L, "Best", 4L, 1L,
8L, "48:88:ca:4f:a7:00", "GRP12689", 757L, "High", 3L, 2L
)
testdat %>%
group_by(WifiMac, `Duplicate.(groups)`) %>%
arrange(desc(GroupID.x))
#> # A tibble: 8 x 7
#> # Groups: WifiMac, Duplicate.(groups) [7]
#> Auto.ID WifiMac GroupID.x VillageId Duplicate `Duplicate.(gro…
#> <int> <chr> <chr> <int> <chr> <int>
#> 1 2 48:88:… GRP18457 1403 Low 1
#> 2 1 48:88:… GRP18450 1403 Low 1
#> 3 3 48:88:… GRP12795 752 Medium 2
#> 4 6 48:88:… GRP12789 752 Medium 2
#> 5 5 48:88:… GRP12788 752 Low 1
#> 6 4 48:88:… GRP12782 752 Low 1
#> 7 7 48:88:… GRP12698 757 Best 4
#> 8 8 48:88:… GRP12689 757 High 3
#> # … with 1 more variable: Desirable.Result <int>
testdat %>%
group_by(WifiMac) %>%
group_by(`Duplicate.(groups)`) %>%
arrange(desc(GroupID.x))
#> # A tibble: 8 x 7
#> # Groups: Duplicate.(groups) [4]
#> Auto.ID WifiMac GroupID.x VillageId Duplicate `Duplicate.(gro…
#> <int> <chr> <chr> <int> <chr> <int>
#> 1 2 48:88:… GRP18457 1403 Low 1
#> 2 1 48:88:… GRP18450 1403 Low 1
#> 3 3 48:88:… GRP12795 752 Medium 2
#> 4 6 48:88:… GRP12789 752 Medium 2
#> 5 5 48:88:… GRP12788 752 Low 1
#> 6 4 48:88:… GRP12782 752 Low 1
#> 7 7 48:88:… GRP12698 757 Best 4
#> 8 8 48:88:… GRP12689 757 High 3
#> # … with 1 more variable: Desirable.Result <int>
Created on 2019-02-26 by the reprex package (v0.2.1)