Learn R Programming

abn (version 3.1.12)

as.data.frame.abnDag: Transform the adjacency matrix representation of a DAG to a data.frame with columns "from" and "to" representing directed edges.

Description

Transform the adjacency matrix representation of a DAG to a data.frame with columns "from" and "to" representing directed edges.

Usage

# S3 method for abnDag
as.data.frame(x, ...)

Value

A data.frame with columns "from" and "to" representing directed edges from parent nodes (from) to child nodes (to)

Arguments

x

An object of class abnDag

...

Additional arguments (currently unused)

Details

The adjacency matrix in abnDag objects has parents in columns and children in rows. A value of 1 at position (i,j) indicates an arc from parent j to child i.

Examples

Run this code
# Create example DAG matrix
mydag <- createAbnDag(dag = ~a+b|a, data.df = data.frame("a"=1, "b"=1))

# Convert to edge list
as.data.frame(mydag)

Run the code above in your browser using DataLab