ggcentrality {netmap} | R Documentation |
Calculate centrality indices for vertices linked to a sf object
Description
Given a sf
object with features that can be linked to a network
or igraph
object, obtain centrality indices for linked features.
Usage
ggcentrality(
n,
m,
lkp = NULL,
m_name = NULL,
n_name = "vertex.names",
par.deg = NULL,
par.bet = NULL,
par.clo = NULL
)
Arguments
n |
A |
m |
A |
lkp |
An optional lookup table. |
m_name |
Optional |
n_name |
Optional |
par.deg |
List with additional optional parameters to functions
|
par.bet |
List with additional optional parameters to functions
|
par.clo |
List with additional optional parameters to functions
|
Value
An sf
object, input m
with added columns for centrality
indices (degree, betweenness, closeness; existing columns with the same name
will be overwritten) and with only the features linked to vertices in input
n
.
Examples
net=network::network(matrix(c(0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0), nrow=4, byrow=TRUE))
network::set.vertex.attribute(net, "name", value=c("a", "b", "c", "d"))
wkb = structure(list("01010000204071000000000000801A064100000000AC5C1641",
"01010000204071000000000000801A084100000000AC5C1441",
"01010000204071000000000000801A044100000000AC5C1241",
"01010000204071000000000000801A024100000000AC5C1841"), class = "WKB")
map=sf::st_sf(id=c("a1", "b2", "c3", "d4"), sf::st_as_sfc(wkb, EWKB=TRUE))
lkptbl=data.frame(id=c("a1", "b2", "c3", "d4"), name=c("a", "b", "c", "d"))
netmap::ggcentrality(net, map, lkptbl, "id", "name")