wt_as_matrix: Convert neighbor or weights list to matrix

View source: R/as_matrix.R

wt_as_matrixR Documentation

Convert neighbor or weights list to matrix

Description

Given a nb list or weights list, convert them to a matrix.

Usage

wt_as_matrix(nb, wt)

nb_as_matrix(nb)

Arguments

nb

a neighbor list—i.e. as created by st_contiguity().

wt

a weights list—i.e. as created by st_weights()

Value

Returns a n x n matrix

Examples


# make a grid
g <- sf::st_make_grid(
  cellsize = c(10, 10),
  offset = c(0, 0),
  n = c(2, 2)
)

# create neighbors
nb <- st_contiguity(g)

# cast to matrix
nb_as_matrix(nb)

# create weights
wt <- st_weights(nb)

# cast as matrix
wt_as_matrix(nb, wt)


JosiahParry/sfdep documentation built on Sept. 7, 2024, 6:15 a.m.