matrix_from_edgelist: Compute the adjacency matrix of a network from its edgelist

Description Usage Arguments Details Value See Also

View source: R/NetworkBuilding.R

Description

Compute the adjacency matrix of a network from its edgelist

Usage

1
2
3
4
5
6
7
matrix_from_edgelist(
  edgelist,
  origin_name = "origin",
  target_name = "target",
  count,
  format_long = F
)

Arguments

edgelist

(data.table) A table containing the edges (or links) of the network, i.e. representing the movements of subjects between facilities. Either in long format with at least two columns (origin and target facilities of a link), each row corresponding to a single movement, or aggregated by unique pairs of origin/target, therefore with an additional variable for movements count (default). See details.

origin_name

(character) Column of the origin facilities of the links.

target_name

(character) Column of the target facilities of the links.

count

(character) Column of the counts of movements by unique pair of facilities.

format_long

(logical) Whether the edgelist is in long format, with each row corresponding to a single movement. If TRUE, the edgelist will be aggregated by unique pairs of facilities to compute the matrix.

Details

The edgelist contains the information on the connections between nodes of the network, that is the movements of subjects between facilities. The edgelist can be in two different formats: long or aggregated. In long format, each row corresponds to a single movement between two facilities, therefore only two columns are needed, one containing the origin facilities of a movement, the other containing the target facilities. In aggregated format, the edgelist is aggregated by unique pairs of origin-target facilities. Thus, each row corresponds to a unique connection between two facilities, and the table contains an additional variable which is the count of the number of movements recorded for the pair. If the edgelist is provided in long format, it will be aggregated to compute the matrix.

Value

A square numeric matrix, the adjacency matrix of the network.

See Also

edgelist_from_base, matrix_from_base


PascalCrepey/HospitalNetwork documentation built on Sept. 16, 2020, 9:56 p.m.