Learn R Programming

rgeoda (version 0.1.0)

get_neighbors: Neighbors of one observation

Description

Get neighbors for idx-th observation, idx starts from 1

Usage

get_neighbors(gda_w, idx)

Value

A numeric vector of the neighbor indices, which start from 1

Arguments

gda_w

A Weight object

idx

A value indicates idx-th observation, idx start from 1

Examples

Run this code
if (FALSE) {
guerry_path <- system.file("extdata", "Guerry.shp", package = "rgeoda")
guerry <- st_read(guerry_path)
queen_w <- queen_weights(guerry)
nbrs <- get_neighbors(queen_w, idx = 1)
cat("\nNeighbors of the 1-st observation are:", nbrs)
}

Run the code above in your browser using DataLab