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 network or igraph object.

m

A sf object.

lkp

An optional lookup table.

m_name

Optional character, name of field in m and of column in lkp.

n_name

Optional character, name of vertex attribute in n and of column in lkp.

par.deg

List with additional optional parameters to functions degree or degree.

par.bet

List with additional optional parameters to functions betweenness or betweenness.

par.clo

List with additional optional parameters to functions closeness or closeness.

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")

[Package netmap version 0.1.4 Index]