View source: R/build_neighbors.R
| build_neighbors | R Documentation |
Identifies neighboring observations or unique spatial locations for a focal observation.
build_neighbors(
coords,
focal_index,
bandwidth,
adaptive = TRUE,
neighbor_unit = c("row", "location"),
location_id = NULL
)
coords |
Numeric matrix or data frame containing spatial coordinates. |
focal_index |
Integer index identifying the focal observation. |
bandwidth |
Numeric bandwidth. For adaptive neighborhoods, this is the number of neighboring rows or unique locations. |
adaptive |
Logical indicating whether an adaptive neighborhood is used. |
neighbor_unit |
Character string indicating whether neighborhoods
are defined using individual data rows ( |
location_id |
Optional vector identifying the spatial location
associated with each observation. Required when
|
A list describing the spatial neighborhood of the focal observation. The list contains:
Integer vector giving the rows of coords
included in the local neighborhood.
Numeric vector containing the distance from the focal location to each selected neighboring row.
Numeric value giving the realized local bandwidth. For adaptive neighborhoods this is the distance to the most distant selected neighbor; for fixed neighborhoods it is the supplied bandwidth.
Numeric vector of distances from the focal location
to all candidate rows or unique locations, depending on neighbor_unit.
Character string indicating whether the neighborhood was constructed using rows or unique locations.
For location-based neighborhoods, the
identifiers of the selected unique locations; NULL for row-based
neighborhoods.
coords <- matrix(
c(0, 0,
1, 0,
2, 0,
3, 0,
4, 0),
ncol = 2,
byrow = TRUE
)
build_neighbors(
coords = coords,
focal_index = 3,
bandwidth = 3,
adaptive = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.