Creates a conditional permutation of neighbors list holding i fixed and shuffling it's neighbors.
Arguments
- nb
a neighbor list.
- seed
default null. A value to pass to
set.seed()
for reproducibily.
Examples
nb <- st_contiguity(guerry)
nb[1:5]
#> [[1]]
#> [1] 36 37 67 69
#>
#> [[2]]
#> [1] 7 49 57 58 73 76
#>
#> [[3]]
#> [1] 17 21 40 56 61 69
#>
#> [[4]]
#> [1] 5 24 79 80
#>
#> [[5]]
#> [1] 4 24 36
#>
# conditionally permute neighbors
perm_nb <- cond_permute_nb(nb)
perm_nb[1:5]
#> [[1]]
#> [1] 77 66 85 76
#>
#> [[2]]
#> [1] 47 1 74 76 51 32
#>
#> [[3]]
#> [1] 29 46 64 58 51 59
#>
#> [[4]]
#> [1] 61 36 62 67
#>
#> [[5]]
#> [1] 63 84 42
#>
# get permuted neighbor weight