Creating an edge list creates a column for each i
position and j
between an observation and their neighbors. You can recreate these values by expanding the nb
and wt
list columns.
library(magrittr)
guerry_nb %>%
tibble::as_tibble() %>%
dplyr::select(nb, wt) %>%
dplyr::mutate(i = dplyr::row_number(), .before = 1) %>%
tidyr::unnest(c(nb, wt))
#> # A tibble: 420 x 3
#> i nb wt
#> <int> <int> <dbl>
#> 1 1 36 0.25
#> 2 1 37 0.25
#> 3 1 67 0.25
#> 4 1 69 0.25
#> 5 2 7 0.167
#> 6 2 49 0.167
#> 7 2 57 0.167
#> 8 2 58 0.167
#> 9 2 73 0.167
#> 10 2 76 0.167
#> # i 410 more rows