pawn | R Documentation |
For one node (argument focus
), finds neighbors among a list of nodes
according to the fool movement.
This movement is orthogonal to the fool()
function. The pawn can only move
vertically, i.e. through a transect.
The detection of neighbors using the fool method can work with
two-dimensional sampling (both transects and quadrats) and
one-dimensional sampling of type quadrats-only.
For sampling of type transects-only, please use the function fool()
.
pawn(nodes, focus, degree = 1, directed = FALSE, reverse = FALSE, self = FALSE)
nodes |
a |
focus |
an |
degree |
an |
directed |
a |
reverse |
a |
self |
a |
This function is internally called by create_edge_list()
but it can be
directly used to 1) understand the neighbors detection method, and 2) to
check detected neighbors for one particular node (focus
).
A subset of the nodes
(data.frame
) where each row is a neighbor
of the focal node.
library("chessboard")
# Two-dimensional sampling (only) ----
sites_infos <- expand.grid("transect" = 1:9, "quadrat" = 1:9)
nodes <- create_node_labels(data = sites_infos,
transect = "transect",
quadrat = "quadrat")
focus <- "5-5"
# Default settings ----
neighbors <- pawn(nodes, focus)
gg_chessboard(nodes) +
geom_node(nodes, focus) +
geom_neighbors(nodes, neighbors)
# Higher degree of neighborhood ----
neighbors <- pawn(nodes, focus, degree = 3)
gg_chessboard(nodes) +
geom_node(nodes, focus) +
geom_neighbors(nodes, neighbors)
# Directed (default orientation) ----
neighbors <- pawn(nodes, focus, degree = 3, directed = TRUE)
gg_chessboard(nodes) +
geom_node(nodes, focus) +
geom_neighbors(nodes, neighbors)
# Directed (reverse orientation) ----
neighbors <- pawn(nodes, focus, degree = 3, directed = TRUE, reverse = TRUE)
gg_chessboard(nodes) +
geom_node(nodes, focus) +
geom_neighbors(nodes, neighbors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.