Learn R Programming

sfdep (version 0.2.5)

st_lag: Calculate spatial lag

Description

Calculates the spatial lag of a numeric variable given a neighbor and weights list.

Usage

st_lag(x, nb, wt, na_ok = FALSE, allow_zero = NULL, ...)

Value

a numeric vector with same length as x

Arguments

x

A numeric vector

nb

A neighbor list object as created by st_neighbors().

wt

A weights list as created by st_weights().

na_ok

Default FALSE. If, TRUE missing values return a lagged NA.

allow_zero

If TRUE, assigns zero as lagged value to zone without neighbors.

...

See ?spdep::lag.listw for more.

See Also

Other stats: local_moran()

Examples

Run this code
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