powered by
Calculates the spatial lag of a numeric variable given a neighbor and weights list.
st_lag(x, nb, wt, na_ok = FALSE, allow_zero = NULL, ...)
a numeric vector with same length as x
x
A numeric vector
A neighbor list object as created by st_neighbors().
st_neighbors()
A weights list as created by st_weights().
st_weights()
Default FALSE. If, TRUE missing values return a lagged NA.
FALSE
TRUE
NA
If TRUE, assigns zero as lagged value to zone without neighbors.
See ?spdep::lag.listw for more.
?spdep::lag.listw
Other stats: local_moran()
local_moran()
geo <- sf::st_geometry(guerry) nb <- st_contiguity(geo) wt <- st_weights(nb) st_lag(guerry$crime_pers, nb, wt)
Run the code above in your browser using DataLab