This function genereates a sparse Matrix from a neighborhood matrix. It bypasses spdep::nb2mat() which leads to a dense matrix representation.

nb2Mat(nb)

Arguments

nb

A nb-class from spdep

Value

A sparse matrix

Author

Lukas Dargel

Examples

nb <- spdep::poly2nb(germany_grid)
nb2Mat(nb)
#> 16 x 16 sparse Matrix of class "ngCMatrix"
#>                                      
#>  [1,] . | | . . . . . . . . . . . . .
#>  [2,] | . | | | | . . . . . . . . . .
#>  [3,] | | . . | | | . . . . . . . . .
#>  [4,] . | . . | . . | | . . . . . . .
#>  [5,] . | | | . | . | | | . . . . . .
#>  [6,] . | | . | . | . | | | . . . . .
#>  [7,] . . | . . | . . . | | . . . . .
#>  [8,] . . . | | . . . | . . | | . . .
#>  [9,] . . . | | | . | . | . | | | . .
#> [10,] . . . . | | | . | . | . | | . .
#> [11,] . . . . . | | . . | . . . | . .
#> [12,] . . . . . . . | | . . . | . | .
#> [13,] . . . . . . . | | | . | . | | |
#> [14,] . . . . . . . . | | | . | . | |
#> [15,] . . . . . . . . . . . | | | . |
#> [16,] . . . . . . . . . . . . | | | .