Description Usage Arguments Value See Also Examples
View source: R/adjmatrix_to_dagitty.R
adjmatrix_to_dagitty
takes as
input an adjacency matrix and converts it to
a dagitty
object.
1 | adjmatrix_to_dagitty(adjmatrix)
|
adjmatrix |
A named adjacency matrix where a 1 in the |
A dagitty
object with the same edge orientations.
dagitty_to_adjmatrix
and bn_to_adjmatrix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | library(orientDAG)
library(dagitty)
library(bnlearn)
library(igraph)
g <- dagitty("dag {
bn [pos=\"0,0\"]
dagitty [pos=\"0.5,-1\"]
adjmatrix [pos=\"1,0\"]
adjmatrix -> dagitty
dagitty -> adjmatrix
bn -> adjmatrix
}")
# Below we can see the conversion directions implemented in this package:
plot(g)
# dagitty -> adjmatrix
adjmatrix <- dagitty_to_adjmatrix(g)
print(adjmatrix)
# adjmatrix -> dagitty
dagitty_obj <- adjmatrix_to_dagitty(adjmatrix)
plot(graphLayout(dagitty_obj))
# bn -> adjmatrix
bn_obj <- empty.graph(c("adjmatrix", "bn", "dagitty"))
amat(bn_obj) <- adjmatrix
plot(bn_obj)
adjmatrix <- bn_to_adjmatrix(bn_obj)
plot(graph_from_adjacency_matrix(adjmatrix))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.