edgelist_to_adjmat_w_attributes: Creates an adjacency matrix from an edgelist with vertex...

Description Usage Arguments Value Examples

View source: R/encode_together.r

Description

The only difference with igraph::graph_from_data_frame is that this returns an 0/1 adjacency matrix and sorts whatever attributes were passed via data accordingly to the network coding.

Usage

1
2
3
edgelist_to_adjmat_w_attributes(edgelist, data,
  data.idvar = colnames(data)[1], ids.to.keep = NULL, data.timevar = NULL,
  edgelist.timevar = NULL)

Arguments

edgelist

A data.frame. Only the first two columns will be used.

data

A data.frame with vertex attributes.

data.idvar

Character scalar. Name of the variable that holds the vertex id (label). By default it uses the first column.

Value

A list with the following

adjmat

A matrix of n\times n.

data

A sorted version of data according to the network coding.

Examples

1
2
3
4
5
6
# Simple example
net <- c("a", "b", "a", "c", "b", "c", "c", "b", "c", "a")
net <- matrix(net, byrow = TRUE, ncol=2)

dat <- data.frame(name = c("d", "a", "c", "b"), age = c(4, 1, 3, 2))
ans0 <- edgelist_to_adjmat_w_attributes(net, dat)

USCCANA/readnet documentation built on May 28, 2019, 3:18 p.m.