as.parental.matrix: Convert a variety of matrix objects to 'parental' objects.

Description Usage Arguments Details Value Examples

View source: R/convert.R

Description

The supplied matrix x should either be an adjacency matrix (type = "adjacency"), or an edgelist (type = "edgelist"). Adjacency matrices should be an n x n matrix A with A[i, j] = 1 if an edge exists between node i and j. Edgelists are of the form returned by which(x == condition, arr.ind = TRUE) for matrices x in adjacency matrix form.

Usage

1
2
3
  ## S3 method for class 'matrix'
 as.parental(x, type = "adjacency", n,
  ...)

Arguments

x

An object of class 'matrix'

type

Either "adjacency" or "edgelist"

n

The number of nodes n. Only required for type = "edgelist"

...

Further arguments (unused)

Details

For type = "edgelist", the number of nodes n must be specified.

Value

An object of class 'parental'.

Examples

1
2
3
4
5
6
7
adjmat <- matrix(sample(c(0, 1), 100, rep = TRUE), 10, 10)
diag(adjmat) <- 0
as.parental(adjmat)

edgelist <- matrix(c(1, 2), nrow = 1, ncol = 2)
colnames(edgelist) <- c("row", "col")
as.parental(edgelist, type = "edgelist", n = 2)

rjbgoudie/parental documentation built on May 27, 2019, 9:11 a.m.